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最好是在点击父组件的地 ...
随机推荐
- UVA 489-- Hangman Judge(暴力串处理)
Hangman Judge In ``Hangman Judge,'' you are to write a program that judges a series of Hangman gam ...
- ios 第三方qq授权登陆,第一次登陆后,再次登陆,失效
这问题找了非常久.最后跟客服联系到.等授权成功后要对 _tencentOAuth 对象释放
- iOS开发-使用Storyboard进行界面跳转及传值
前言:苹果官方是推荐我们将所有的UI都使用Storyboard去搭建,Storyboard也是一个很成熟的工具了.使用Storyboard 去搭建所有界面,我们可以很迅捷地搭建出复杂的界面,也就是说能 ...
- git创建分支
1.创建本地分支名称为dev的本地分支 git branch dev 2.将本地分支添加到远程分支 git push origin dev 3.查看创建的本地分支, 带有*符号的分支,代表当前所在分支 ...
- .NET程序性能优化基本要领
想了解更多关于新的编译器的信息,可以访问 .NET Compiler Platform ("Roslyn") 基本要领 在对.NET 进行性能调优以及开发具有良好响应性的应 ...
- UVA 1660 Cable TV Network
题意: 求一个无向图的点连通度. 分析: 把一个点拆成一个入点和一个出点,之间连一条容量为1的有向边,表示能被用一次.最大流求最小割即可.套模板就好 代码; #include <iostream ...
- asp.net application
Application 对象用于存储和访问来自任何页面的变量,类似于 session 对象.不同之处在于,所有的用户分享一个 Application 对象,而 session 对象和用户的关系是一一对 ...
- C# 根据年月获得此月第一天和最后一天,并计算工作日
string str = "2015年3月"; ); ); , secondIndex - firstIndex - ); , ); DateTime dt = DateTime. ...
- dom 删除和清除
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- HDU 1027 - Ignatius and the Princess II
第 m 大的 n 个数全排列 DFS可过 #include <iostream> using namespace std; int n,m; ]; bool flag; ]; void d ...