I assume you want an event handler method to be executed in the CodeBehind when user selects a value in the
DropDownList
inside the
GridView
. To do this, I have the following suggestions:
After the line
DropDownList drptype1;
drptype1 = (DropDownList)(e.Row.FindControl("drpitem"));
Add the following line of code to add a
SelectedIndexChanged
event handler to the
DropDownList
:
drptype1.SelectedIndexChanged += new EventHandler(DropDownList_SelectedIndexChanged);
And, define the EventHandler
DropDownList_SelectedIndexChanged
in the CodeBehind as follows:
void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if (ddl != null)
{
string selectedValue = ddl.SelectedItem.Value;
string selectedText = ddl.SelectedItem.Text;
}
}