All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SqlServer数据库触发器实例讲解_[SQL,Server教程]
Asp.Net,Forms验证(自定义、角色提供程序、单点登录)_[Asp.Net教程]
ASP.NET,2.0处理Null值_[Asp.Net教程]
凸显个性,网页右键菜单我作主_JavaScript技术_编程技术
关于PHP字符集的问题_php资料_编程技术
SQL Server的空值处理策略_[SQL Server教程]
在sqlserver2005中安装sql server 2000的示例数据库_[SQL Server教程]
用SQL,Server,Prompt提高开发能力_[SQL,Server教程]
XML入门教程-向XML文件存储数据_[XML教程]
ASP.NET数据库编程快速入门之技术慨述_[Asp.Net教程]
Reading number is top 10 pictures
含苞欲放的素颜美少女3
战场废物1
The little woman's bright wire1
The money of more than 100 countries and regions3
Fat bird to fly
Ashlynn Brooke a group sexy photo2
恶搞漫画2
Hunan province aizhai super-large suspension bridge open to traffic and 4 world first1
Chinese paper-cut grilles art appreciation7
六种更聪明的工作方法
Download software ranking
The Bermuda triangle3
WebService在.NET中的实战应用教学视频 → 第4集
Boxer's Top ten classic battle9
dreamweaver8中文版
徐若瑄成名作“魔鬼天使”
少妇苏霞全本
豪门浪荡史
Tram sex maniac 2 (H) rar bag18
Take off clothes to survival
C++教程第四版
归海一刀 published in(发表于) 2014/1/30 1:01:33 Edit(编辑)
DropDownList联动简单实例_[Asp.Net教程]

DropDownList联动简单实例_[Asp.Net教程]

DropDownList联动简单实例_[Asp.Net教程]

在编程中选中某项的方法:

DropDownList1.ClearSelection();
DropDownList1.Items.FindByValue(st.Year.ToString()).Selected = true;


如果不清空选中项的话,会出现:不能在 DropDownList 中选择多个项。


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);
}
}

不过我遇到的不是这个问题,是个Bug,关机再开就能运行,奇怪。而且VS2005IDE键位还变了,删除行变成了Ctrl+Y(VB的习惯),恢复预置环境就好了。

看来遇到问题还是要冷静:可以采用的处理方法是:祈祷一句,骂一句,睡一觉,关机一次。

下面附一个最基本的实例。主要,要实现联动DropDownList1的AutoPostBack属性要开。

Default.aspx


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





无标题页















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;
}
}


来源:http://www.cnblogs.com/lqb





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.