DropDownList四级联动
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="iframe_dropdown.aspx.cs" Inherits="Admin_iframe_dropdown" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div style="float: left" >
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" Width="105px" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" Width="105px"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="true" Width="105px"
OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="true" Width="105px"
OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div style="float: left" >
</div> </form>
</body>
</html>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Text; public partial class Admin_iframe_dropdown : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
Db1DataBind();
Db2DataBind();
Db3DataBind();
Db4DataBind();
}
} protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Db2DataBind();
Db3DataBind();
Db4DataBind();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Db3DataBind();
Db4DataBind();
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
Db4DataBind();
}
protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{ } public void Db1DataBind()
{
string sqlStr = "select ModID,ModName,ParentID from Modules where ParentID=0000";
FillDropList(sqlStr, DropDownList1); }
public void Db2DataBind()
{
int PreID = Convert.ToInt32(DropDownList1.SelectedValue);
string sqlStr1 = "Select ModID,ModName,ParentID from Modules where ParentID='" + PreID.ToString() + "'";
FillDropList(sqlStr1, DropDownList2);
}
public void Db3DataBind()
{
int PreID = Convert.ToInt32(DropDownList2.SelectedValue);
string sqlStr2 = "Select ModID,ModName,ParentID from Modules where ParentID='" + PreID.ToString() + "'";
FillDropList(sqlStr2, DropDownList3);
}
public void Db4DataBind()
{
string PreID = Convert.ToString(DropDownList3.SelectedValue);
string sqlStr3 = "Select ModID,ModName,ParentID from Modules where ParentID='" + PreID.ToString() + "'";
FillDropList(sqlStr3, DropDownList4);
}
public void FillDropList(string SQLString, DropDownList drp)
{
SqlConnection connection = new SqlConnection("database=ZJExpress;server=(local);uid=sa;pwd=hellocheng");
SqlCommand cmd = new SqlCommand(SQLString, connection);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds, "DropList");
drp.DataSource = ds.Tables["DropList"].DefaultView;
drp.DataTextField = ds.Tables["DropList"].Columns[].ColumnName;
drp.DataValueField = ds.Tables["DropList"].Columns[].ColumnName;
drp.DataBind();
}
}
参考链接http://blog.csdn.net/wxd_860825/article/details/4563368
DropDownList四级联动的更多相关文章
- C# 使用winForm的TreeView显示中国城镇四级联动
直接上代码吧,这里 MySql.Data.MySqlClient;需要到mysql官网下载mysql-connector-net-6.9.8-noinstall.zip 访问密码 6073 usi ...
- jq完成省市区街道四级联动
之前看的省市区街道四级联动的插件,感觉和公司要求的有些不符合,就自己写了一个 因为要读取本地json文件,所以要跑下服务器 下载browser-sync 然后在项目目录下运行browser-sync ...
- discuz 自带的地区四级联动调用方法
首先,DZ提供了专门处理地区信息的函数,在source/function/function_profile.php(第14行)文件中:function profile_setting(){}那么,我们 ...
- .net DropDownList静态联动
1.前台 <span id="spnClient" style="margin-left: 30px; margin-top: 10px"> < ...
- 省市县 三级 四级联动Javascript JQ 插件PCASClass.js
想要使用这款组件,需要页面引入 PCASClass.js 核心文件,该文件在您的HTML文档<head>标签之内. <script type="text/javascrip ...
- js 四级联动
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
- ASP .NET DropDownList多级联动事件
思路 假如有三级省.市.区,先加载出所有省选择省之后,加载出该省所有市选择市之后,加载出该市所有区重新选择省,则清空市和区重新选择市,则清空区想好数据结构,不同的数据结构做法不同 例子 数据结构 pu ...
- dropdownlist 二级联动
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GradeBind(); } } //绑定 ...
- 地址四级联动的vue组件
一.效果图如下: 二.思路 主要在vue中结合 mint-ui组件的Picker和Popup方法,负责对json地址进行展示: 三.代码地址 四.说明 address4.json最好是在点击父组件的地 ...
随机推荐
- sql的基本查询语句
--------------------------------------------基本常用查询-------------------------------------- 自己简单练习做了个表. ...
- javascript第十三课:Json
js中的json就是字典,Dictionary,就是字典的简化创建方式,json的遍历使用for in的方式,进行遍历 遍历复杂json格式 (如果数组里面存储的是键值对的话,字符串最好用双引号) v ...
- 通过P-SMR看State Machine Replication
在一个复制系统中,为了保持一致性,各个replicated server是串行运行.这样性能上就会比仅仅有一台server的系统慢,由于仅仅有一台server能够进行并行处理.假设在复制系统中各个se ...
- About Quick Packaging and Custom Packaging
About Quick Packaging and Custom Packaging The Enterprise Manager Support Workbench provides two met ...
- CSS中为什么overflow:hidden能清除浮动(float)的影响?原理是什么?
http://www.zhihu.com/question/30938856 父块没有设置指定的高宽,当子块设置为浮动后,原本包裹子块的父块的高度塌陷消失,这时给父块设置overflow:hidden ...
- 普通用户登录Oracle DB Control
使用 sys 或者 system 用户登录 Oracle DB Control 是没有问题的. 但是,如果是普通的用户需要登录Oracle DB Control,建表或者视图之类的, 则需要授权 SE ...
- The executable was signed with invalid entitlements新设备run出现这个问题
出现这个问题一般是新手不熟悉开发者发布流程造成地 一定要安开发者流程一步一步走 这样就不会出错了 注意这几个地方地设置 1.
- autorelease方法
基本用法: 1,autorelease 方法会返回对象本身 2,调用完autorelease方法后,对象的计数器不变 2,autorelease 会将对象放到一个自动释放池中 3,当自动释放池被销 ...
- C# 2 闰年平年 老狼几点了
作业 第一题 老狼几点了.凌晨,上午,下午,晚上. static void Main (string[] args) { //输入 Console.Write("老狼老狼几点了?" ...
- I/O重定向与管道
1.输出重定向 (1)> 覆盖输出 (2)>> 追加输出 (3) set -C: 禁止对已经存在文件使用覆盖重定向: 强制覆盖输出,则使用 >| set +C: 关闭上述功 ...