无限级下拉列表框控件

link1.支持无限级分类,自动生成所需的DropDownList。
2.设置简单,只需传入特定格式的xml数据源即可。
3.客户端无刷新操作,支持服务器端Post回发操作。
4.主要属性:
   LastLevelID:获取或设置最后一个级别的选择值。
   XmlString:获取或设置xml数据源。
   DropdownlistColl:获取存放所有下拉列表的集合对象。

-----------------------------------------------------------------------------
下图为指定格式的xml数据源。


下图为效果图:
MDemo.gif
以下为调用代码:
None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Configuration;
None.gif
using  System.Collections;
None.gif
using  System.Web;
None.gif
using  System.Web.Security;
None.gif
using  System.Web.UI;
None.gif
using  System.Web.UI.WebControls;
None.gif
using  System.Web.UI.WebControls.WebParts;
None.gif
using  System.Web.UI.HtmlControls;
None.gif
using  System.IO;
None.gif
None.gif
public  partial  class  Tmp : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if (!Page.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//获取xml文件数据源(也可以从数据库中获取数据动态生成xml)。
InBlock.gif
            StreamReader sr = new StreamReader(Server.MapPath("~/JScripts/ab.xml"), System.Text.Encoding.Default);
InBlock.gif            
string XmlString = sr.ReadToEnd();
InBlock.gif            
//设置控件的xml数据源属性。
InBlock.gif
            this.multiDr1.XmlString = XmlString;
InBlock.gif            
//获取或设置控件的最后一个级别的选择值。
InBlock.gif            
//如果不设置此属性,将以xml默认的顺序绑定。
InBlock.gif
            this.multiDr1.LastLevelID = "86-003-005-008";
InBlock.gif            
//绑定。
InBlock.gif
            this.multiDr1.DataBind();
InBlock.gif            sr.Close();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

InBlock.gif    
protected void Button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
//获取控件最后一个级别的选择值。
InBlock.gif
        Response.Write("最后一个级别的选择值:" + this.multiDr1.LastLevelID);
InBlock.gif
InBlock.gif        
//遍历控件的存放所有DropDownList的集合对象。
InBlock.gif
        foreach (DropDownList d in this.multiDr1.DropdownlistColl)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Response.Write(
"<br/>ID:" + d.ID + ",数量:" + d.Items.Count.ToString() + ",选择项的文本: " + d.SelectedItem.Text + ",选择项的值:" + d.SelectedItem.Value);
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

控件下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值