Attention: We are retiring the ASP.NET Community Blogs. Learn more >

RowDataBound and the different states conditions

I constantly need to look this up and always see post surround this subject.  The following condition will aide you in determining the state the row is in in a GridView.  The real key is the first statement.

If (e.Row.RowState And DataControlRowState.Edit) > 0 Then
'Edit Row
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
'Data Rows
ElseIf e.Row.RowType = DataControlRowType.Header Then
'Header Row
ElseIf e.Row.RowType = DataControlRowType.Footer Then
'Footer Row
ElseIf e.Row.RowType = DataControlRowType.EmptyDataRow Then
'Empty Row
End If

 

No Comments