I've created dynamic dropdownlist in gridview rowdatabound pls refer below code.
DropDownList ddlResult = new DropDownList();
ddlResult.ID = "ddlResult";
ddlResult.AutoPostBack = true;
ddlResult.SelectedIndexChanged += ddlResult_SelectedIndexChanged;
ddlResult.Items.Insert(0, new ListItem("PASS", "0"));
ddlResult.Items.Insert(1, new ListItem("FAIL", "1"));
I've a button below the gridview, when i click the button i wants to access and get the above dropdown selected value. like below code inside click event
foreach (GridViewRow row in gvMark.Rows)
{
DropDownList drpResult = (DropDownList)row.FindControl("ddlResult");
Result = drpResult.SelectedValue.ToString();
What I have tried:
DropDownList ddlResult = new DropDownList();
ddlResult.ID = "ddlResult";
ddlResult.AutoPostBack = true;
ddlResult.SelectedIndexChanged += ddlResult_SelectedIndexChanged;
ddlResult.Items.Insert(0, new ListItem("PASS", "0"));
ddlResult.Items.Insert(1, new ListItem("FAIL", "1"));
foreach (GridViewRow row in gvMark.Rows)
{
DropDownList drpResult = (DropDownList)row.FindControl("ddlResult");
Result = drpResult.SelectedValue.ToString();