GridView中实现DropDownList联动
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data; public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//如果是数据绑定行
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlParent = (DropDownList)e.Row.FindControl("ddlParent");
GetParent(ddlParent);
}
} private void GetParent(DropDownList ddl)
{
string sql = "select * from Models where ParentModuleID=0";
DataTable dt = DB.CreateDT(sql);
ddl.DataTextField = "ModuleName";
ddl.DataValueField = "ID";
ddl.DataSource = dt;
ddl.DataBind();
}
protected void ddlParent_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((sender) as Control).NamingContainer;
DropDownList ddlParent = (sender) as DropDownList; int ddlParentID=Convert.ToInt32(ddlParent.SelectedValue); DropDownList ddlChildren = row.FindControl("ddlChildren") as DropDownList;
GetChildren(ddlChildren,ddlParentID); } private void GetChildren(DropDownList ddl, int parentID)
{
string sql = "select * from Models where ParentModuleID=" + parentID + "";
DataTable dt = DB.CreateDT(sql);
ddl.DataTextField = "ModuleName";
ddl.DataValueField = "ID";
ddl.DataSource = dt;
ddl.DataBind();
}
}
GridView中实现DropDownList联动的更多相关文章
- GridView 中绑定DropDownList ,下拉框默认选中Label的值
在GridView中,我们 有时候要绑定值. 前台绑定的代码可以这样 <asp:TemplateField HeaderText="当前状态" ItemStyle-Horiz ...
- 为GridView中的DropDownList赋值
<Bda:GridView ID="gvMessage" runat="server" Height="70px" Width=&qu ...
- Gridview中绑定DropDownList
1.页面代码 <asp:TemplateField HeaderText="等级"> ...
- GridView中给DropDownList动态绑定数据,及选择列表值后自动更新数据库
protected void sgvFile1_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList ddlAM = ( ...
- Js获取Gridview中Dropdownlist选中状态
在Gridview中加入Dropdownlist模板列,加入DropDownlist 是一种常用的操作,其中涉及到如何获取选择项和Gridview重新绑定两个要点. 如图 前台代码如下 <%@ ...
- GridView中两个DropDownList联动
GridView中两个DropDownList联动 http://www.cnblogs.com/qfb620/archive/2011/05/25/2057163.html Html: <as ...
- DEV控件中GridView中的复选框与CheckBox实现联动的全选功能
最初的界面图如图1-1(全选框ID: cb_checkall DEV控件名称:gcCon ): 要实现的功能如下图(1-2 1-3 1-4)及代码所示: 图1-2 图1-3 图1-4 O(∩_∩ ...
- 如何解决FormView中实现DropDownList连动选择时出现 "Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用" 的错误
原文:如何解决FormView中实现DropDownList连动选择时出现 "Eval().XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用" 的 ...
- MVC编辑状态两个DropDownList联动
前几天使用jQuery在MVC应用程序中,实现了<jQuery实现两个DropDownList联动(MVC)>http://www.cnblogs.com/insus/p/3414480. ...
随机推荐
- JDK,JRE,JVM,三者的区别于联系?
万事开头难,从基础抓起! 下载JDK官网:http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK:Java Dev ...
- Swift3.0P1 语法指南——继承
原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...
- PHP 站点相对包含,路径的问题解决方法(include,require)
以前看了,很多框架,基本上很少使用相对路径包含.而一般很多做php web站点,喜欢用相对路径. 认为这样,无论目录放到那里. 只要跟另外目录关系一致.那么就不会出现问题.如果一个站点,一般都认为,如 ...
- centos 7配置网络 更新yum源
cd /etc/sysconfig/network-script/ 找到对应的ifcfg-entxxxx文件,然后添加网关,修改dhcp为static,静态ip,添加IPADDR ip地址.onboo ...
- Https方式使用Git@OSC设置密码的方式
Https方式使用Git@OSC设置密码的方式 62561_silentboy Zoker3 years ago member https方式每次都要输入密码,按照如下设置即可输入一次就不用再手输入密 ...
- apache极简配置虚拟机
在apache的httpd.conf文件最后添加: Listen 81<VirtualHost *:81> DocumentRoot E:/CM/wx_shop/ecshop</Vi ...
- Java Native Interface 六JNI中的异常
本文是<The Java Native Interface Programmer's Guide and Specification>读书笔记 在这里只讨论调用JNI方法可能会出现的异常, ...
- tab 切换写法
<script> var oUL = document.getElementById('aboutTab-ul'); var oLi = oUL.getElem ...
- Java读取word文件,字体,颜色
在Android读取Word文件时,在网上查看时可以用tm-extractors,但好像没有提到怎么读取Word文档中字体的颜色,字体,上下标等相关的属性.但由于需要,要把doc文档中的内容(字体,下 ...
- python re模块search()与match()区别
re.search()搜索字符串并返回结果. 整个字符串搜索. re.match()匹配字符串并返回结果 从开始处匹配. 所以,match()可以理解为search()的一个子集.