gridview关于dropdownlist问题
<ItemTemplate>
<asp:Label ID= "lbl4 " runat= "server " Text= ' <%# Eval( "POWER_NAME ") %> '> </asp:Label>
<asp:DropDownList ID= "dl1 " runat= "server " Visible= "false " Width= "100 " > </asp:DropDownList>
</ItemTemplate>
我想让点击编辑按钮后让dl1默认选中的值等于lbl4的值。
我在page_load里面
for (int i = 0; i < this.gv1.Rows.Count; i++)
{
((DropDownList)this.gv1.Rows[i].Cells[2].FindControl( "dl1 ")).SelectedValue = this.gv1.Rows[i].Cells[2].Text;
}
不行。
请大侠帮忙
------解决方案--------------------foreach (GridViewRow row in GridViewBookShop.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl( "dl1 ");
.......
}
------解决方案--------------------foreach (GridViewRow row in gv1.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl( "dl1 ");
.......
}
------解决方案--------------------试成功了?