Checking Alternate Rows for Edit Mode in GridView RowDataBound

I am used RowDataBound event for a GridView control on my application. I want to detect the rows for edit mode to do some code in RowDataBound event. For which I wrriten the below code.
  1. if ((e.Row.RowState == DataControlRowState.Edit) && (e.Row.RowType == DataControlRowType.DataRow))  
  2. {  
  3.      // Logic here.  
  4. }  
The above code worked fine only with Normal rows state(1, 3, 5... (non-alternating rows). But This piece of code not working if the row state is Alternate for edit mode (2,4,6.. (Alternating rows).
 
When I debug the code, the e.Row.RowState for alternate rows gives me the value something like "Alternate | Edit". That's means it RowState contains more than one value using bit-logic.
 
For more read about this read DataControlRowState Enumeration.
 
Solutions:
 
So, the solutions of above problem is to check the row state value as follows:
  1. if (((e.Row.RowState & DataControlRowState.Edit) > 0) && (e.Row.RowType == DataControlRowType.DataRow))  
  2. {  
  3.    // Logic here.
  4. }