0

我知道如何获得事件 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();
        }
    }
4

1 回答 1

1

你可以得到 gridview TemplateField 控件为

foreach (GridViewRow row in yourGrid.Rows)
{
     Control ctrl = row.FindControl("Drop_Responsaveis");
     DropDownList ddl = ctrl as DropDownList;
     ddl.items.add(something);
 }
于 2013-03-13T20:16:00.970 回答