急!在线等!有答案马上结分。请高手过来看看!!!高难问题关于dropdownlist的四级联动!!!!???

zooo 2004-12-03 09:26:49
高难问题关于dropdownlist的四级联动!!!!???有四个dropdownlist控件一起联动!!!
有做过的请指教一下!!
...全文
254 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
zooo 2004-12-03
  • 打赏
  • 举报
回复
进入修改页面后,怎么可以让它的选项值是开始选定的值,而不是默认的哪?
zooo 2004-12-03
  • 打赏
  • 举报
回复
那我弄一下
TonyTonyQ 2004-12-03
  • 打赏
  • 举报
回复
不是挖苦你啦,只是觉得这个问题问出来很奇怪而已,呵呵。你换种问法说“如何实现联动的无刷新和高效率”这个确实是难问题。要实现联动,楼上2位的方法都可以用,但都会刷新页面而且数据多了的话,会很慢~~~
lsl2008 2004-12-03
  • 打赏
  • 举报
回复
帮你顶啊,好难!
Eddie005 2004-12-03
  • 打赏
  • 举报
回复
将前3个dropdownlist的autopostback属性设为true;
private void InitializeComponent()
{
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}

private void DindDDLST(DropDownList ddlst,string parentid)
{
string sql = "select * from table1 where parentid = '" + parentid + "'";
//读取数据绑定ddlst
}
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DropDownList2.Items.Clear();
this.DropDownList3.Items.Clear();
this.DropDownList4.Items.Clear();
DindDDLST(this.DropDownList2,this.DropDownList1.SelectedValue);
}
如此类推;

2)修改前用ViewState记录所有选中的情况,保存后重新绑定;
或者不要重新绑定,而是保存成功后直接修改dropdownlist的当前item
beyondjay 2004-12-03
  • 打赏
  • 举报
回复
在dropdownlist1的SelectedIndexChanged里面写事件,绑定dropdownlist2,逐渐的下去~~

private void dropdownlist1_SelectedIndexChanged(object sender, System.EventArgs e)
{
dropdownlist2.DataSource=xxx;
dropdownlist2.DataTextField="xxxxxx";
dropdownlist2.DataValueField="xxxxxx_ID";
dropdownlist2.DataBind();
dropdownlist2.Items.Insert(0,"请选择");
}
xuandme000 2004-12-03
  • 打赏
  • 举报
回复
我们用javascript+xml实现过3级的也是从数据库中取数据,
发现速度不是很快,而且会有闪烁的显现,不知有没有其他的办法!
zooo 2004-12-03
  • 打赏
  • 举报
回复
晕 qzj(SoldierQ)大哥,我要是会,就不在这费劲了
不告诉你也不用挖苦人吧
zooo 2004-12-03
  • 打赏
  • 举报
回复
对了忘了补充一句,数据都是在数据库里面的,并且要求在修改的时候dropdownlist选项为当初选的项目!!!!
TonyTonyQ 2004-12-03
  • 打赏
  • 举报
回复
一级一级联动,不是很简单的嘛~~~~
haoztao 2004-12-03
  • 打赏
  • 举报
回复
帮你顶啊,好难!
duxinrun 2004-12-03
  • 打赏
  • 举报
回复
实际上问题的本质就是有没有足够快的方法用JS实现索引或者哈希表,对吧。
有点灵感没,线性时间的四级联动: ^_^

lansluo 2004-12-03
  • 打赏
  • 举报
回复
怎么实现最简单的4级联动,你只要看上面回复人: Eddie005(♂) 暴赱 『零零伍』 (︶︵︶) ( ) 信誉:100 2004-12-03 09:57:00 得分: 0

就可以知道个大概了。

如果不需要无刷新,速度等要求,那个就可以

但是如果要求无刷新,速度,我也很想知道
Reaky 2004-12-03
  • 打赏
  • 举报
回复
up
zooo 2004-12-03
  • 打赏
  • 举报
回复
晕!!!!
我现在就是想知道怎么样4级联动!
xxqqpp 2004-12-03
  • 打赏
  • 举报
回复
其实4级联动并不是大问题,难的是怎样实现联动还要不刷新
zooo 2004-12-03
  • 打赏
  • 举报
回复
各位大哥,我弄不出来了!
原码贴出来谁帮我看看啊!!!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;

namespace qdfz.company
{
/// <summary>
/// liandong 的摘要说明。
/// </summary>
public class liandong : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.DropDownList DropDownList3;
protected System.Web.UI.WebControls.DropDownList DropDownList4;

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{

string ConnectString = "server=localhost;database=qdfz;uid=sa;pwd=123";
string QueryString = "select * from class1";

SqlConnection myConnection = new SqlConnection(ConnectString);
SqlDataAdapter myCommand = new SqlDataAdapter(QueryString, myConnection);


DataSet ds = new DataSet();
myCommand.Fill(ds, "DropDownList1");


DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "class1_name";
DropDownList1.DataValueField = "class1_name";
DropDownList1.DataBind();


}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.DropDownList2.SelectedIndexChanged += new System.EventHandler(this.DropDownList2_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
private void DindDDLST(DropDownList ddlst,string parentid)
{

string sql = "select * from class2 where class1_name = '" + parentid + "'";

}
private void DindDDLST1(DropDownList ddlst2,string parentid2)
{

string sql = "select * from class1 where parentid2 = '" + parentid2 + "'";
//读取数据绑定ddlst
}
private void DindDDLST2(DropDownList ddlst3,string parentid3)
{

string sql = "select * from class1 where parentid3 = '" + parentid3 + "'";
//读取数据绑定ddlst
}
private void DindDDLST3(DropDownList ddlst4,string parentid4)
{

string sql = "select * from class1 where parentid4 = '" + parentid4 + "'";
//读取数据绑定ddlst
}
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
{
this.DropDownList2.Items.Clear();
this.DropDownList3.Items.Clear();
this.DropDownList4.Items.Clear();
DindDDLST(this.DropDownList2,this.DropDownList1.SelectedValue);
}

}

private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
{

this.DropDownList3.Items.Clear();
this.DropDownList4.Items.Clear();
DindDDLST1(this.DropDownList2,this.DropDownList2.SelectedValue);

}
private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
{


this.DropDownList4.Items.Clear();
DindDDLST1(this.DropDownList3,this.DropDownList3.SelectedValue);

}
private void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
{



DindDDLST1(this.DropDownList4,this.DropDownList4.SelectedValue);

}
}
}
conquersky 2004-12-03
  • 打赏
  • 举报
回复
我有asp的 要不要 留邮箱
zooo 2004-12-03
  • 打赏
  • 举报
回复
Eddie005(♂) 暴赱 『零零伍』 (︶︵︶)
帮人就帮到底吧
private void DindDDLST(DropDownList ddlst,string parentid)
中的
DropDownList ddlst怎么写????
zooo 2004-12-03
  • 打赏
  • 举报
回复
qzj(SoldierQ):
我用 Eddie005(♂) 暴赱 『零零伍』 (︶︵︶) 的方法存入数据库字段
然后在进入“修改”页面时用dropdownlist.selectedindex=dropdownlist.items.indexof(dropdownlist.items.FindByValue("Value"))
就可以在当前项显示我存入数据库的数据了吧??
加载更多回复(4)

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧