我想实现的多级联动好像跟网上查到的一些还不太一样。
不是类似于省,市,县的那种联动
是类似于电脑配件选择的联动,也就是说,第一项不但只影响第二项,也会对第三项产生影响
这三项不存在主次关系。每一项都会影响到其他的项,也就是类似于选配电脑时,各个配件之间的关系。
请问这样的多级联动该如何实现。
不是类似于省,市,县的那种联动
是类似于电脑配件选择的联动,也就是说,第一项不但只影响第二项,也会对第三项产生影响
这三项不存在主次关系。每一项都会影响到其他的项,也就是类似于选配电脑时,各个配件之间的关系。
请问这样的多级联动该如何实现。
解决方案 »
- |zyciis| 如何让js文件里面可以写asp.net的及时代码,谢谢
- 谁能讲一下netcms中的频道?多谢
- treeview 中__doPostBack('TreeView1','s系统维护\\工作组\\工作人员')缺少对象 请各位高手指点 急啊 呜呜
- 在cs中怎样获得checkbox的值
- asp.net中有没有提供收取邮件的类或者组件(在线)
- 在线急问:如何在VS.NET 2003 开发环境中建立如下文件?
- 【新手问题】数据绑定的问题,哪位大哥帮帮我。
- ASP.NET页面优化方式
- 如何在生成TreeView控件的时候就把它展开?
- 如何判断用户输入的是中文还是英文或数字?
- 关于ASP.net中SESSION 和 Cookie的疑问,采用的SQLServer会话状态模式
- html怎么用vs2005写后台
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="area.ascx.cs" Inherits="Global_area" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdateProduct" runat="server">
<ContentTemplate>
<asp:DropDownList ID="province" runat="server" AutoPostBack="True" OnSelectedIndexChanged="province_SelectedIndexChanged" style="border:1px solid #D1D1D1;">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="city" runat="server" AutoPostBack="True" OnSelectedIndexChanged="city_SelectedIndexChanged" style="border:1px solid #D1D1D1;">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="area" runat="server" style="border:1px solid #D1D1D1;">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>area.aspx.csusing System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
using BLL.Common;
using System.IO;
public partial class Global_area : System.Web.UI.UserControl
{
private string provinceid = "110000";
private string cityid = "0";
private string areaid = "0"; public string Provinceid
{
get { return provinceid; }
set { provinceid = value; }
}
public string Cityid
{
get { return cityid; }
set { cityid = value; }
}
public string Areaid
{
get { return areaid; }
set { areaid = value; }
}
public string getprivincevalue()
{
return this.province.SelectedValue;
}
public string getcityvalue()
{
return this.city.SelectedValue;
}
public string getareavalue()
{
return this.area.SelectedValue;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindprovince(provinceid);
bindcity(province.SelectedValue,cityid);
bindarea(city.SelectedValue, areaid);
}
}
public void province_SelectedIndexChanged(object sender, EventArgs e)
{
bindcity(province.SelectedValue, cityid);
bindarea(city.SelectedValue, areaid);
}
public void bindprovince(string provinceid)
{
//初始化省
DataTable dt = PublicFunc.iniprovince();
province.DataSource = dt;
province.DataTextField = "province";
province.DataValueField = "provinceid";
province.DataBind();
foreach(ListItem li in province.Items)
{
if(li.Value==provinceid)
{li.Selected=true;}
}
}
public void bindcity(string provinceid, string cityid)
{
//初始化市
string sql = "select * from city where father="+provinceid;
string filepath = AppSetting.UpLoadPath + "/city";
if (!Directory.Exists(Server.MapPath(filepath)))
{
BLL.Common.Helper.FolderUtility.CreateFolder(Server.MapPath(filepath));
}
string filename = Server.MapPath(filepath + "/city_"+provinceid+".xml");
DataSet ds = new DataSet(); if (File.Exists(filename))
{
ds.ReadXml(filename, XmlReadMode.ReadSchema); }
else
{
ds = SqlHelper.ExecuteDataset(AppSetting.ConnStr, CommandType.Text, sql); ds.WriteXml(filename, XmlWriteMode.WriteSchema);
}
city.DataSource = ds.Tables[0];
city.DataTextField = "city";
city.DataValueField = "cityid";
city.DataBind();
city.Items.Insert(0, new ListItem("--不限--", "0"));
foreach (ListItem li in city.Items)
{
if (li.Value == cityid)
{ li.Selected = true; }
}
} public void bindarea(string cityid,string areaid)
{
//初始化市
string sql = "select * from area where father=" + cityid;
string filepath = AppSetting.UpLoadPath + "/city";
if (!Directory.Exists(Server.MapPath(filepath)))
{
BLL.Common.Helper.FolderUtility.CreateFolder(Server.MapPath(filepath));
}
string filename = Server.MapPath(filepath + "/area_" + cityid + ".xml");
DataSet ds = new DataSet(); if (File.Exists(filename))
{
ds.ReadXml(filename, XmlReadMode.ReadSchema); }
else
{
ds = SqlHelper.ExecuteDataset(AppSetting.ConnStr, CommandType.Text, sql); ds.WriteXml(filename, XmlWriteMode.WriteSchema);
}
area.DataSource = ds.Tables[0];
area.DataTextField = "area";
area.DataValueField = "areaid";
area.DataBind();
area.Items.Insert(0, new ListItem("--不限--", "0"));
foreach (ListItem li in area.Items)
{
if (li.Value == areaid)
{ li.Selected = true; }
}
} public void city_SelectedIndexChanged(object sender, EventArgs e)
{
bindarea(city.SelectedValue, areaid);
}}
http://www.google.cn/search?client=pub-5434506002917399&prog=aff&channel=2000052003&q=ajaxToolkit%20Cascadingdropdown
晕哦,怎么实现都可以啊。只要你能用 select 语句把你每个 dl里想要的列表显示出来都行
我给你假设三种数据
1. WD台式机1T硬盘,
2. Intel CoreDual2 3.2G CPU
3. kingstone 笔记本2G DDR2 800 内存那么这类数据是有层次的,其实还是级联,两层关系
电脑--台式机--cpu,硬盘,内存,主板,显卡
|--笔记本--cpu,硬盘,内存,主板,显卡
cpu,硬盘,内存,主板,显卡可以抽象出来,但要加一个属性(字段加以区分)比如 is_notebook
用于处理那些独特的数据比如笔记本上特有的配件
这样分来就需要两个及以上的表。
我主张分三个表
1 Fenlei(分类) 2 Leibie(类别) 3 Jilu(记录)
表1的内容
id 1
name 台式机
...
表2
id 1
name 硬盘
list 1
is_notebook NULL
...
id n
name 笔记本触摸板
list n
is_notebook True表3
id 1
name WD台式机1T硬盘
Fenlei_id 1
Leibie_id 1
neirong 内容当如果选择了笔记本 那么select不需要限制条件 如果选了台式机那么要加 select * from leibie where is_notebook <> 'True'...我也是闲的慌Orz