private void dgClass_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int index = e.Item.ItemIndex;
this.dgClass.EditItemIndex = index;
// 设置下拉列表
DropDownList drp=(DropDownList)e.Item.FindControl("TempClassName");
this.BindRepclass(drp);
this.BindGrid();//绑定类别下拉菜单
private void BindRepclass(DropDownList control)
{
SqlDataReader dr = this.dbo.RunSQL("SELECT * FROM Rep_Class ORDER BY class_id", null);
control.DataSource = dr;
control.DataBind();
dr.Close();
}
<EditItemTemplate>
<asp:DropDownList id="TempClassName" runat="server" Width="96px" DataTextField="class_name" DataValueField="class_id"></asp:DropDownList>
</EditItemTemplate>
我怎么在编辑的时候怎么也动态帮定到下来菜单上面,总说我控件没找到,
{
int index = e.Item.ItemIndex;
this.dgClass.EditItemIndex = index;
// 设置下拉列表
DropDownList drp=(DropDownList)e.Item.FindControl("TempClassName");
this.BindRepclass(drp);
this.BindGrid();//绑定类别下拉菜单
private void BindRepclass(DropDownList control)
{
SqlDataReader dr = this.dbo.RunSQL("SELECT * FROM Rep_Class ORDER BY class_id", null);
control.DataSource = dr;
control.DataBind();
dr.Close();
}
<EditItemTemplate>
<asp:DropDownList id="TempClassName" runat="server" Width="96px" DataTextField="class_name" DataValueField="class_id"></asp:DropDownList>
</EditItemTemplate>
我怎么在编辑的时候怎么也动态帮定到下来菜单上面,总说我控件没找到,
http://singlepine.cnblogs.com/articles/266538.html
如果你想实现的是在datagrid中有一个dropdown控件,然后可以选择这个下拉框的化, 我提示你要在datagrid的itemdatabind事件中处理,否则不行的
zhudao92(藏马啸天) ( ) 信誉:93 Blog 2007-01-18 10:40:35 得分: 0
DropDownList drp=(DropDownList)e.Item.Cells[1].FindControl("TempClassName");
行 138: {
行 139: SqlDataReader dr = this.dbo.RunSQL("SELECT * FROM Rep_Class ORDER BY class_id", null);
行 140: control.DataSource = dr;
行 141: control.DataBind();
行 142: dr.Close();
14行包错
还是不行啊,郁闷死了~~~
{
DropDownList drp=(DropDownList)e.Item.FindControl("TempClassName");
this.BindRepclass(drp);
}