久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

DropDownList聯(lián)動(dòng)簡(jiǎn)單實(shí)例

 悟靜 2012-01-30
在編程中選中某項(xiàng)的方法:
DropDownList1.ClearSelection();
DropDownList1.Items.FindByValue(st.Year.ToString()).Selected = true;


如果不清空選中項(xiàng)的話,,會(huì)出現(xiàn):不能在 DropDownList 中選擇多個(gè)項(xiàng)。
 

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
int year = int.Parse(DropDownList1.SelectedValue);
int month = int.Parse(DropDownList2.SelectedValue);
int day = DateTime.DaysInMonth(year, month);
DropDownList3.Items.Clear();
for (int i = 1; i <= day; i++)
{
ListItem newItem = new ListItem(i.ToString(), i.ToString());
DropDownList3.Items.Add(newItem);
}
}

不過(guò)我遇到的不是這個(gè)問(wèn)題,,是個(gè)Bug,,關(guān)機(jī)再開(kāi)就能運(yùn)行,奇怪,。而且VS2005IDE鍵位還變了,,刪除行變成了Ctrl+Y(VB的習(xí)慣),恢復(fù)預(yù)置環(huán)境就好了,。

看來(lái)遇到問(wèn)題還是要冷靜:可以采用的處理方法是:祈禱一句,,罵一句,睡一覺(jué),,關(guān)機(jī)一次,。

下面附一個(gè)最基本的實(shí)例。主要,,要實(shí)現(xiàn)聯(lián)動(dòng)DropDownList1的AutoPostBack屬性要開(kāi),。

Default.aspx
 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www./1999/xhtml" >
<head runat="server">
<title>無(wú)標(biāo)題頁(yè)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList></div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
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;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
for (int i = 2001; i < 2031; i++)
{
DropDownList1.Items.Add(new ListItem(c(i)));
}
for (int i = 1; i < 13; i++)
{
DropDownList2.Items.Add(new ListItem(c(i)));
}
for (int i = 1; i < 32; i++)
{
DropDownList3.Items.Add(new ListItem(c(i)));
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.Items.Clear();
int days = DateTime.DaysInMonth(int.Parse(DropDownList1.SelectedValue), int.Parse(DropDownList2.SelectedValue));
for (int i = 1; i <= days; i++)
{
DropDownList3.Items.Add(new ListItem(c(i)));
}
}
string c(int i)
{
string u = i.ToString();
if (u.Length == 1) { u = "0" + u; }
return u;
}
}
 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多