K
keithb
I have dropdown list in a gridview column edit template. It works OK, except
when I edit a row, the dropdown list does not initialize to the existing
value that shows in the textbox that displays in the item template. I tried
to initialize the selected value of the dropdown list with some lines of
code in the grid_RowEditing event but I get an error that I do not
understand. The error occurs at this line of code:
String DelID =
((DropDownList)grid.Rows[e.NewEditIndex].FindControl("DelDropDownList")).Text;
the error is: "Object reference not set to an instance of an object."
I do not understand this, because code from the grid_RowUpdating event that
runs error-free is the same except that it uses e.RowIndex instead of
e.NewEditIndex and both indexes have the same value. Can someone shed some
light on this for me?
Thanks,
Keith
when I edit a row, the dropdown list does not initialize to the existing
value that shows in the textbox that displays in the item template. I tried
to initialize the selected value of the dropdown list with some lines of
code in the grid_RowEditing event but I get an error that I do not
understand. The error occurs at this line of code:
String DelID =
((DropDownList)grid.Rows[e.NewEditIndex].FindControl("DelDropDownList")).Text;
the error is: "Object reference not set to an instance of an object."
I do not understand this, because code from the grid_RowUpdating event that
runs error-free is the same except that it uses e.RowIndex instead of
e.NewEditIndex and both indexes have the same value. Can someone shed some
light on this for me?
Thanks,
Keith