I have a GridView, each row has Edit button. After it's clicked, one of the columns turns into a drop down list where users can select value. Edit button becomes Update - so very simple usual scenario.
Now, I don't seem to be able to grab the selected drop down list after Update is clicked. Here is my code:
protected void gv_UpdateRow(string arg)
{
int currentIndex = gv.EditIndex;
gv.EditIndex = -1;
GridViewRow currentRow = gv.Rows[currentIndex];
try
{
string value2 = ((DropDownList)currentRow.FindControl("ddlValueTwo")).SelectedItem.ToString();
}
catch
{
Response.Write("error");
}
BindGridView();
}
So basically, the program execution always ends up at the catch statement. I have checked and drop down list is found, the exception is thrown when selected item is not found.
What gives?
I use c# asp.net 2.0 web forms