博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 后台三级联动
阅读量:5298 次
发布时间:2019-06-14

本文共 5081 字,大约阅读时间需要 16 分钟。

1,DropDownList属性AutoPostBack="True"

2,放在UpdatePanel内,用UpdatePanel后,只对UpdatePanel内的控件做数据绑定,不会对UpdatePanel外的control做操作(包括事件也不会触发)

3,一个UserControl占用页面的一行。

4,每个UserControl在页面上都是一个Div,可以用Div属性设置大小

5,Control之间的间距可以用<table>来接近:<table cellpadding="0"; cellspacing="0"; ><td style="padding-left:0px" >

 

6,联动可以用JavaScript完成,但是不能做成UserControl,因为JavaScript上要getElementsByID

问题不明,JavaScript不熟悉

 

<table cellpadding="0"; cellspacing="0"; style=" border:-1 none">

<tr style=" letter-spacing: 0px">
<td style="padding-left: 0px">
Dept. / Group / Section / Unit&nbsp;<asp:DropDownList ID="ddlDept" runat="server"
AutoPostBack="True" OnSelectedIndexChanged="ddlDept_SelectedIndexChanged" Width="105px">
<asp:ListItem Value="0">-select dept-</asp:ListItem>
</asp:DropDownList>
</td>
<td style="padding-left:0px">
<asp:DropDownList ID="ddlGroup" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlGroup_SelectedIndexChanged"
Width="105px">
<asp:ListItem Value="0">-select group-</asp:ListItem>
</asp:DropDownList>
</td>
<td style=" padding-left:0px">
<asp:DropDownList ID="ddlSection" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlSection_SelectedIndexChanged"
Width="105px">
<asp:ListItem Value="0">-select section-</asp:ListItem>
</asp:DropDownList>
</td>
<td style=" padding-left:0px">
<asp:DropDownList ID="ddlUnit" runat="server" AutoPostBack="True" Width="105px">
<asp:ListItem Value="0">-select unit-</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>

 

 

#region 属性

private bool isEnable = true;

public bool IsEnable

{
get { return isEnable; }
set { isEnable = value; }
}
private bool isDeptVisible = true;

public bool IsDeptVisible

{
get { return isDeptVisible; }
set { isDeptVisible = value; }
}
private bool isGroupVisible = true;

public bool IsGroupVisible

{
get { return isGroupVisible; }
set { isGroupVisible = value; }
}
private bool isSectionVisible = true;

public bool IsSectionVisible

{
get { return isSectionVisible; }
set { isSectionVisible = value; }
}
private bool isUnitVisible = true;

public bool IsUnitVisible

{
get { return isUnitVisible; }
set { isUnitVisible = value; }
}

public string dept_id

{
get
{
return ddlDept.SelectedItem.Value.ToString();
}
set
{
if (value is string)
{
ddlDept.SelectedItem.Value = value;
ddlDept_SelectedIndexChanged(null, null);
}
}
}
public string group_id
{
get
{
return ddlGroup.SelectedItem.Value.ToString();
}
set
{
if (value is string)
{
ddlGroup.SelectedItem.Value = value;
ddlGroup_SelectedIndexChanged(null, null);
}
}
}
public string section_id
{
get
{
return ddlSection.SelectedItem.Value.ToString();
}
set
{
if (value is string)
{
ddlSection.SelectedItem.Value = value;
ddlSection_SelectedIndexChanged(null, null);
}
}
}
public string unit_id
{
get
{
return ddlUnit.SelectedItem.Value.ToString();
}
set
{
if (value is string)
{
ddlUnit.SelectedItem.Value = value;
}
}
}
public DataTable dtResult(string dbTable)
{
DataTable dt = new DataTable();
return dt;
}
#endregion 属性

protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
is_inventory_holding_unit.DDLBind(ddlDept, "dept", null);
this.ddlDept.Items.Insert(0, new ListItem("-select dept-", "0"));
}
ddlDept.Enabled = IsEnable;
ddlGroup.Enabled = IsEnable;
ddlSection.Enabled = IsEnable;
ddlUnit.Enabled = IsEnable;

ddlDept.Visible = IsDeptVisible;

ddlGroup.Visible = IsGroupVisible;
ddlSection.Visible = IsSectionVisible;
ddlUnit.Visible = IsUnitVisible;

}

protected void ddlDept_SelectedIndexChanged(object sender, EventArgs e)
{
this.ddlGroup.Items.Clear();
this.ddlSection.Items.Clear();
this.ddlUnit.Items.Clear();
is_inventory_holding_unit.DDLBind(ddlGroup, "group", ddlDept.SelectedItem.Value.ToString());
this.ddlGroup.Items.Insert(0, new ListItem("-select group-", "0"));
this.ddlSection.Items.Insert(0, new ListItem("-select section-", "0"));
this.ddlUnit.Items.Insert(0, new ListItem("-select unit-", "0"));
}

protected void ddlGroup_SelectedIndexChanged(object sender, EventArgs e)

{
this.ddlSection.Items.Clear();
this.ddlUnit.Items.Clear();
is_inventory_holding_unit.DDLBind(ddlSection, "section", ddlGroup.SelectedItem.Value.ToString());
this.ddlSection.Items.Insert(0, new ListItem("-select section-", "0"));
this.ddlUnit.Items.Insert(0, new ListItem("-select unit-", "0"));
}

protected void ddlSection_SelectedIndexChanged(object sender, EventArgs e)

{
this.ddlUnit.Items.Clear();
is_inventory_holding_unit.DDLBind(ddlUnit, "unit", ddlSection.SelectedItem.Value.ToString());
this.ddlUnit.Items.Insert(0, new ListItem("-select unit-", "0"));
}

 

#region Load时赋值

public void dept(string id)
{
is_inventory_holding_unit.DDLBind(ddlDept, "dept", null);
ddlDept.SelectedValue = id;
ddlDept_SelectedIndexChanged(null, null);
}
public void group(string id)
{
ddlGroup.SelectedValue = id;
ddlGroup_SelectedIndexChanged(null, null);
}
public void section(string id)
{
ddlSection.SelectedValue = id;
ddlSection_SelectedIndexChanged(null, null);
}
public void unit(string id)
{
if (id == null)
return;
if (id == "")
return;

ddlUnit.SelectedValue = id;

}
#endregion 

转载于:https://www.cnblogs.com/tom527/archive/2012/03/21/2409157.html

你可能感兴趣的文章
php手机验证码源码,php验证码实现源码
查看>>
php fpm高并发,php服务器高并发优化思路
查看>>
php gd 图像翻转,php(gd库)输出中文图像的转换函数
查看>>
java 表头添加复选框,表头带有CheckBox可以实现全选的jtable
查看>>
java b组 小计算器,简单计算器..
查看>>
php server port,$_SERVER[‘SERVER_PORT’]关于php5.2一个bug
查看>>
php 类 init,PHP内核探索:类的定义
查看>>
java的二叉树树一层层输出,Java构造二叉树、树形结构先序遍历、中序遍历、后序遍历...
查看>>
meep php,麻省理工时域差分软件 MEEP windows 下编译开发(一)——准备工作
查看>>
matlab的清除0,matlab中的平均值clear %清除变量dx=0.01*2*pi; %间隔x=0:dx:2*pi; %自变量向量y=...
查看>>
php 循环套 重复,php 循环套循环 出现重复数据
查看>>
mysql distince,MySQL学习(未完待续)
查看>>
php libevent 定时器,PHP 使用pcntl和libevent实现Timer功能
查看>>
对数字进行 混淆 php,解密混淆的PHP程序
查看>>
zencart不支持php7的原因,Zen Cart1.3.8产品页报错提示:Deprecated: Function ereg_replace() is deprecated...
查看>>
php仿阿里巴巴,php实现的仿阿里巴巴实现同类产品翻页
查看>>
matlab fis编辑器在哪,基本FIS编辑器
查看>>
linux的串口子系统,TTY子系统
查看>>
linux查看cpu目录,linux常用命令-查看cpu、内存、磁盘和目录空间
查看>>
修改linux远程22端口,linux修改ssh远程端口22
查看>>