Friday 23 March 2007

RowDataBound checking if row is in edit mode

The RowState property of a grid row can hold more than one value using bitwise logic.
If you want to test if a row is in edit mode then use:

if ((e.Row.RowState & DataControlRowState.Edit) > 0)

The RowState will also have a value of DataControlRowState.Alternate for every other row.