我知道如何在templatefield
事件中获得RowDataBound
的价值:
Control ctrl = e.Row.FindControl("Drop_Responsaveis");
DropDownList ddl = ctrl as DropDownList;
ddl.items.add(something);
但我需要在button_Click
事件中获得它的价值......我该怎么做?
@Siz S回答解决方案
foreach (GridViewRow gvr in GridView1.Rows)
{
string str = ""
Control ctrl = gvr.FindControl("Drop_Responsaveis");
if (ctrl != null)
{
DropDownList ddl = ctrl as DropDownList;
str= ddl.SelectedItem.ToString();
}
}
答案 0 :(得分:1)
你可以将gridview TemplateField控件作为
foreach (GridViewRow row in yourGrid.Rows)
{
Control ctrl = row.FindControl("Drop_Responsaveis");
DropDownList ddl = ctrl as DropDownList;
ddl.items.add(something);
}