没办法了,找大家帮忙。。
<EditItemTemplate>
<asp:DropDownList ID= "DropDownList2 " runat= "server ">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID= "Label1 " runat= "server " Text= ' <%# Bind( "Order_By ") %> '> </asp:Label>
</ItemTemplate>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList DropDown2 = (DropDownList)e.Row.FindControl( "DropDownList2 ");
}
为何取不到值,不光这里取不到,在RowCreated也取不到,
------解决方案--------------------if (e.Row.RowType == DataControlRowType.DataRow)
------解决方案--------------------因为
<EditItemTemplate>
<asp:DropDownList ID= "DropDownList2 " runat= "server ">
</asp:DropDownList>
</EditItemTemplate>
这里肯定不行!如果在RowDataBound事件中的话,需要在ItemTemplate/AlternatingItemTemplate加入相应控件
------解决方案--------------------if (e.Row.RowState == DataControlRowState.Edit)
{
DropDownList DropDown2 = (DropDownList)e.Row.FindControl( "DropDownList2 ");
}