Question

In asp.net 3.5 I have a DataGrid. It has several rows of data. I have radio buttons out of the datagrid. The data grid has a column for drop down list in EDIT mode. So I click one of the radio buttons and it does a postback. I want to know in this check changed event for radio button if any of the rows in DataGrid are in edit mode. How do I do that? I can loop through the DataGrid like this

For Each item As DataGridItem In dgEditTime.Items
        Trace.Warn("The item index is:" & item.ItemIndex)

    Next

But how to find out if what row is in edit mode?

Was it helpful?

Solution

If you are using a GridView you can get the EditIndex by calling:

int editIndex = yourGridView.EditIndex 

If you are using the old DataGrid control, you can call EditItemIndex:

int editIndex = yourDG.EditItemIndex

If your code doesn't work as you expect, is likely that you are probably rebinding the data on every postback and hence, the EditItemIndex (or EditIndex depending on the actual control you are using) is therefore reset to the original state.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top