protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = getFL(0); DropDownList1.DataSource = dt;
DropDownList1.DataBind();
DropDownList1.SelectedIndex = -1;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string selectvalue = DropDownList1.SelectedValue; DropDownList2.Items.Clear();
if (DropDownList1.SelectedValue == "")
{
DropDownList2.Items.Add(new ListItem("请选择"));
return;
}
int selectvalues = Convert.ToInt32(selectvalue);
DataTable dt = getFL(selectvalues);
DropDownList2.DataSource = dt;
DropDownList2.DataBind();
DropDownList2.SelectedIndex = 0;
} protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string Selectvalue = DropDownList2.SelectedValue;
DropDownList3.Items.Clear();
if (DropDownList2.SelectedValue == "")
{
DropDownList3.Items.Add(new ListItem("请选择"));
return;
}
int Selectvalues = Convert.ToInt32(Selectvalue);
DataTable dt = getFL(Selectvalues);
DropDownList3.DataSource = dt;
DropDownList3.DataBind();
}
我想在一开始的时候DropDownList1显示请选择,Drop2和Drop3为空,当Drop1选中后,Drop2显示为请选择,Drop3还是为空,Drop2选中时,Drop3为请选择
这需要怎么写?请高手帮帮忙 我是小白 请尽量写清楚一些 谢谢了
{
if (!Page.IsPostBack)
{
DataTable dt = getFL(0); DropDownList1.DataSource = dt;
DropDownList1.DataBind();
DropDownList1.SelectedIndex = -1;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string selectvalue = DropDownList1.SelectedValue; DropDownList2.Items.Clear();
if (DropDownList1.SelectedValue == "")
{
DropDownList2.Items.Add(new ListItem("请选择"));
return;
}
int selectvalues = Convert.ToInt32(selectvalue);
DataTable dt = getFL(selectvalues);
DropDownList2.DataSource = dt;
DropDownList2.DataBind();
DropDownList2.SelectedIndex = 0;
} protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string Selectvalue = DropDownList2.SelectedValue;
DropDownList3.Items.Clear();
if (DropDownList2.SelectedValue == "")
{
DropDownList3.Items.Add(new ListItem("请选择"));
return;
}
int Selectvalues = Convert.ToInt32(Selectvalue);
DataTable dt = getFL(Selectvalues);
DropDownList3.DataSource = dt;
DropDownList3.DataBind();
}
我想在一开始的时候DropDownList1显示请选择,Drop2和Drop3为空,当Drop1选中后,Drop2显示为请选择,Drop3还是为空,Drop2选中时,Drop3为请选择
这需要怎么写?请高手帮帮忙 我是小白 请尽量写清楚一些 谢谢了
解决方案 »
- 今天在别人的项目里发现GlobalResources,想问一下,写在这里面有什么好处啊?
- 查询问题的调取
- 取出文本内容中的第一张图像?
- 如何设置Button的背景色
- 请大家指教:js前台取gridview值的问题
- 谁帮我改改这个页面哦。谢谢拉
- 如何管理ObjectDataSource缓存的数据?
- 值不能为空,参数名:string
- 什么情况下用SQL语句直接更新数据库?什么时候需要操作离线的DATASET中的DATATABLE中的DATAROW,然后再UPDATE()去更新??
- 这是怎么回事
- MVC3做的一个得到当前班级的Cookie,为什么cookie的Key出现了2次,
- DEC加密、解密的问题
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebTest.WebForm3" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text="请选择" Value="0" Selected="True"></asp:ListItem>
<asp:ListItem Text="项目1" Value="1"></asp:ListItem>
<asp:ListItem Text="项目2" Value="2"></asp:ListItem>
<asp:ListItem Text="项目3" Value="3"></asp:ListItem>
</asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server"
onselectedindexchanged="DropDownList2_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text=" " Value="-1" Selected="True"></asp:ListItem>
<asp:ListItem Text="请选择" Value="0" ></asp:ListItem>
<asp:ListItem Text="项目1" Value="1"></asp:ListItem>
<asp:ListItem Text="项目2" Value="2"></asp:ListItem>
<asp:ListItem Text="项目3" Value="3"></asp:ListItem>
</asp:DropDownList> <asp:DropDownList ID="DropDownList3" runat="server">
<asp:ListItem Text=" " Value="-1" Selected="True"></asp:ListItem>
<asp:ListItem Text="请选择" Value="0"></asp:ListItem>
<asp:ListItem Text="项目1" Value="1"></asp:ListItem>
<asp:ListItem Text="项目2" Value="2"></asp:ListItem>
<asp:ListItem Text="项目3" Value="3"></asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebTest
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue!="0")
{
DropDownList2.SelectedValue = "0";
}
else
{
DropDownList2.SelectedValue = "-1";
}
} protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList2.SelectedValue != "0")
{
DropDownList3.SelectedValue = "0";
}
}
}
}
DropDownList的数据绑定的话自己去写下就好了。
http://www.cnblogs.com/insus/archive/2011/07/04/2097059.html