gridview中的dropdownlist 级联 在gridview中有两个dropdownlist这种情况下,如何做级联呢。那个SelectedIndexChanged不知道怎样去弄了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考:protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e){ GridViewRow gvr = (sender as DropDownList).NamingContainer as GridViewRow; if(gvr != null) { DropDownList ddl = gvr.FindControl("DropDownList2") as DropDownList; if(ddl != null) { ddl.DataSource = "你要绑定的数据源"; ddl.DataTextField = "设置DataTextField"; ddl.DataValueField = "设置DataValueField"; ddl.DataBind(); } }} protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow){if (e.Row.FindControl("DropDownList1") != null){DropDownList ddl = ( DropDownList)e.Row.FindControl(" DropDownList1");ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);}}}protected void ddl_SelectedIndexChanged(object sender, EventArgs e){DropDownList Type = sender as DropDownList;TableCell cell = (TableCell)Type.Parent; GridViewRow item = (GridViewRow)cell.Parent; } 找DropDownList的事件selectIndexChanged,在属性栏可以设置。帮楼主顶了。 请教:winform 中picturebox 和 panel 在线等,一个简单的问题 反复使用大数组导致内存溢出? DataTable序列化,反序列化问题 DataTable的用法?? 如何调用Windows资源管理器打开指定的目录并且把指定的文件设置为选中状态 还是搞不定邮件的解码! 三层架构中的数据校验怎么写到Model类中。net2.0环境。 socket 高手请进 有没有用c#写的读取mp3的tag信息的例子啊? usb口能单纯地输出高电平吗 如何分割曲线?
参考:protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow gvr = (sender as DropDownList).NamingContainer as GridViewRow;
if(gvr != null)
{
DropDownList ddl = gvr.FindControl("DropDownList2") as DropDownList;
if(ddl != null)
{
ddl.DataSource = "你要绑定的数据源";
ddl.DataTextField = "设置DataTextField";
ddl.DataValueField = "设置DataValueField";
ddl.DataBind();
}
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.FindControl("DropDownList1") != null)
{
DropDownList ddl = ( DropDownList)e.Row.FindControl(" DropDownList1");
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
}
}
}
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList Type = sender as DropDownList;
TableCell cell = (TableCell)Type.Parent;
GridViewRow item = (GridViewRow)cell.Parent; }
帮楼主顶了。