drowdownlist的数据并不是从数据库中取出来的,是在代码里加上的,而且还要实现两个drowdownlist都有个空的情况,drowdownlist1选空的话,drowdownlis2变为空,能帮我写一个吗?!!!!!!!! 我搜了无数个例子都不行,所以来麻烦大家了!drowpdownlist1的值:
空,A,B
dropdowlist2:
空,
A:aaa,bbb
B:ccc,ddd
就是这个效果
哪位大哥抽空帮我做个完整的例子行吗???!(vb.net)分不够在加
(不要javascript实现的那种,必须用dropdownlist)
空,A,B
dropdowlist2:
空,
A:aaa,bbb
B:ccc,ddd
就是这个效果
哪位大哥抽空帮我做个完整的例子行吗???!(vb.net)分不够在加
(不要javascript实现的那种,必须用dropdownlist)
解决方案 »
- access数据库默认值
- 网站打开竟成了不知名的东西?????
- 怎么保存用户上一次登陆信息
- 删除Web References文件夹
- .NET页面中table导出XLS,有代码,有疑问,求解答
- 关于asp.net操作Excel问题,散分!祝快出生的女儿健康。
- 急。。急。。很急 .net 随即生成个四位数,是否包含4
- ASP.NET 同时获得存储过程返回的记录集和数值两种数据
- 急..求一sql 存储过程写法
- 关于CheckBox和RadioButton二个控件的char()字段和它们转换的写法?
- 请问大家,这真是个不可能完成的任务吗?:光标从一个文本框离开后,到数据库取出一个值,放到另一个文本框中
- 页面上有一个runat=server的HTMLSELECT控件,我点击按钮时怎么拿不到它所选的值啊??奇怪!!
If Not Page.IsPostBack Then
Dim listitem As ListItem
listitem = New ListItem()
listitem.Text = ""
DropDownList1.Items.Add(listitem)
listitem = New ListItem()
listitem.Text = "A"
DropDownList1.Items.Add(listitem)
listitem = New ListItem()
listitem.Text = "B"
DropDownList1.Items.Add(listitem)
End If
End SubPrivate Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
DropDownList2.Items.Clear()
Dim listitem As ListItem
Select Case DropDownList1.SelectedItem.Text
Case ""
listitem = New ListItem()
listitem.Text = ""
DropDownList2.Items.Add(listitem)
Case "A"
listitem = New ListItem()
listitem.Text = "aaa"
DropDownList2.Items.Add(listitem)
listitem = New ListItem()
listitem.Text = "bbb"
DropDownList2.Items.Add(listitem)
Case "B"
listitem = New ListItem()
listitem.Text = "ccc"
DropDownList2.Items.Add(listitem)
listitem = New ListItem()
listitem.Text = "ddd"
DropDownList2.Items.Add(listitem)
End Select
End Sub
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True"></asp:DropDownList>
<asp:DropDownList id="DropDownList2" runat="server"></asp:DropDownList>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></FONT>
</form>
</body>
</HTML>WebForm1.aspx.vbImports System.Collections
Imports System.Web.UI.WebControls
Public Class WebForm1
Inherits System.Web.UI.Page#Region " Web 窗体设计器生成的代码 " '该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList '注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not Page.IsPostBack Then
DropDataBind()
End If
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
If Me.DropDownList1.SelectedValue.Trim() = "" Then
Me.DropDownList2.SelectedIndex = 0
ElseIf Me.DropDownList1.SelectedValue.Trim() = "A" Then
Me.DropDownList2.SelectedIndex = 1
ElseIf Me.DropDownList1.SelectedValue.Trim() = "B" Then
Me.DropDownList2.SelectedIndex = 2
End If End Sub
Private Sub DropDataBind()
With Me.DropDownList1
.Items.Add(New ListItem(" ", ""))
.Items.Add(New ListItem("A", "A"))
.Items.Add(New ListItem("B", "B"))
End With
With Me.DropDownList2
.Items.Add(New ListItem(" ", ""))
.Items.Add(New ListItem("aaa", "aaa"))
.Items.Add(New ListItem("bbb", "bbb"))
End With
End Sub
End Class
----------------------------------------------------------------------
欢迎试用ASP.NET大文件上传组件(UpLoadModule 1.1.2004.0720 & 无刷新进度条)
http://www.cnblogs.com/lion.net/archive/2004/07/20/25987.aspx
UpLoadModule为您提供了这样的一个方案,该方案除了允许你上传大文件外,还能实时显示上传进度并捕获上传中的错误信息。允许无商业目的个人用户免费使用。
----------------------------------------------------------------------
欢迎试用HtmlEditor(在线文本编辑器)
http://www.cnblogs.com/lion.net/archive/2004/07/15/24296.aspx
她是一个网页的在线文本编辑器,她能够在网页上实现许多桌面编辑软件(如:Word)所具有的强大可视编辑功能;她是一个真正的绿色软件,不需要在计算机上安装任何的客户端软件;并且她是完全开放源代码的,允许无商业目的个人用户免费使用。
----------------------------------------------------------------------
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;namespace WA1
{
public struct Jeng
{
private string ahmy1;
private string ahmy2; public string Ahmy1
{get{return this.ahmy1;}}
public string Ahmy2
{get{return this.ahmy2;}}
public Jeng(string a,string b)
{
ahmy1 = a;
ahmy2=b;
}
}
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
ArrayList ls1 = new ArrayList();
ArrayList ls2 = new ArrayList();
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
ls1.Add(new Jeng("a1","a1"));
ls1.Add(new Jeng("a2","a2"));
ls1.Add(new Jeng("a3","a3"));
ls1.Add(new Jeng("a4","a4"));
ls1.Add(new Jeng("a5","a5"));
this.DropDownList1.DataSource = ls1;
this.DropDownList1.DataBind();
this.DropDownList1.AutoPostBack = true; ls2.Add(new Jeng("b1","b1"));
ls2.Add(new Jeng("b0","b0"));
this.DropDownList2.DataSource = ls2;
this.DropDownList2.DataBind(); //DropDownList2.DataSource = ls;
//DropDownList2.DataBind();
}
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//ls.Clear();
if(DropDownList1.SelectedValue=="a1")
{
ls2.Clear();
ls2.Add(new Jeng("b1","b1"));
ls2.Add(new Jeng("b0","b0"));
this.DropDownList2.DataSource = ls2;
this.DropDownList2.DataBind();
}
else
{
ls2.Clear();
ls2.Add(new Jeng("b2","b2"));
ls2.Add(new Jeng("b3","b3"));
this.DropDownList2.DataSource = ls2;
this.DropDownList2.DataBind();
}
}
}
}
//以上是.cs文件
//以下是aspx文件
//原谅我没有用vb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DropDownList id="DropDownList1" DataTextField="ahmy1" DataValueField="ahmy2" runat="server"></asp:DropDownList>
<asp:DropDownList id="DropDownList2" DataTextField="ahmy1" DataValueField="ahmy2" runat="server"></asp:DropDownList></FONT>
</form>
</body>
</HTML>
ddl1.items.add("A");
ddl1.items.add("B");
ddl1.selectedindex=ddl1.items.indexof(ddl1.items.findbytext(""));ddl2.items.add("");
ddl2.items.add("aaa,bbb");
ddl2.items.add("ccc,ddd");
ddl2.selectedindex=ddl2.items.indexof(ddl2.items.findbytext(""));ddl1_selectedindexchanged()中
if (ddl1.selecteditems.text=="")
ddl2.selecteditems.text="";