编辑页面

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div> </div>
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" AutoPostBack="True" Height="50px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" style="margin-bottom: 0px" >
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Width="100px" AutoPostBack="True" Height="50px" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server" Width="100px" AutoPostBack="True" Height="50px">
</asp:DropDownList>
</form>
</body>
</html>

编辑cs

public partial class Test2 : System.Web.UI.Page
{
public DataClassesDataContext context; protected void Page_Load(object sender, EventArgs e)
{
context = new DataClassesDataContext();
if(!IsPostBack)
{
databind("");
datashibind("");
dataxianbind("");
} }
private void databind(string parentareacode)
{ var querydata = from q in context.ChinaStates
where q.ParentAreaCode == parentareacode
select q;
DropDownList1.DataSource = querydata;//指定数据源 //DropDownList1.Items.Insert(0,new ListItem("请选择单位")); DropDownList1.DataTextField = "AreaName";//界面上显示的是地名
DropDownList1.DataValueField = "AreaCode";//存的是地区编号 DropDownList1.DataBind(); }
private void datashibind(string parentareacode)
{
var querydata = from q in context.ChinaStates
where q.ParentAreaCode ==parentareacode
select q;
DropDownList2.DataSource = querydata; DropDownList2.DataTextField = "AreaName";//界面上显示的是地名
DropDownList2.DataValueField = "AreaCode";//存的是地区编号
DropDownList2.DataBind(); }
private void dataxianbind(string parentareacode)
{ var querydata = context.ChinaStates.Where(r=>r.ParentAreaCode==parentareacode);
DropDownList3.DataSource = querydata;
DropDownList3.DataTextField = "AreaName";//界面上显示的是地名
DropDownList3.DataValueField = "AreaCode";//存的是地区编号
DropDownList3.DataBind(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string code = DropDownList1.SelectedValue.ToString();
datashibind(code);
if (DropDownList2.Items.Count > )
{
string s = DropDownList2.SelectedItem.Value.ToString();
dataxianbind(s);
}
else
{
DropDownList3.Items.Clear();
} }
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string code = DropDownList2.SelectedValue.ToString();
dataxianbind(code); }
}

最新文章

  1. mono for android Json 上传文件
  2. javascript 减少回流
  3. Windows7系统下JAVA运行环境下载、安装和设置(第二次更新:2012年03月14日)
  4. POJ 2299 逆序对
  5. 一、XML语法
  6. ios NSMethodSignature and NSInvocation 消息转发
  7. Python下划线的使用 _ __ __obj__
  8. html base2
  9. Linux中“is not in the sudoers file”解决方法
  10. Oracle创建视图view权限不足问题剖析
  11. Django rest framework源码分析(3)----节流
  12. python正则表达式--编译正则表达式re.compile
  13. position三种属性的区别
  14. 剑指offer用位运算实现两个数相加,及python相关的位操作
  15. 解决使用Mybatis 传入多参数使用map封装遇到的 “坑”问题
  16. Ubuntu18---安装Redis和简单使用Redis
  17. C.【转】C语言字符串与数字相互转换
  18. Promise,async/await解决回调地狱
  19. Orchard模块开发全接触4:深度改造前台
  20. [QT][SQLITE]学习记录一 querry 查询

热门文章

  1. WPF ListBox
  2. sysbench 安装遇到的问题
  3. [经验交流] Active-Active 方式设置 kubernetes master 多节点高可用
  4. Android生命周期
  5. 扫描二维码自动识别手机系统(Android/IOS)
  6. ubuntu 安装redis两种方式 教程
  7. (document).height()与$(window).height()
  8. CRM Setstate plugin
  9. yum提示This system is not registered with RHN.RHN support will be disabled.
  10. SQL Server 2014 SP2发布下载:数十项更新修复