这个要怎样实现?
比如现在是 2008年 DropDownList 项要有2007 2008 如果是2009年就添加一个就行 VALUE 要想对应的 2007年就是2007 2008年就是2008
请前辈们指导一下。要怎样做?
比如现在是 2008年 DropDownList 项要有2007 2008 如果是2009年就添加一个就行 VALUE 要想对应的 2007年就是2007 2008年就是2008
请前辈们指导一下。要怎样做?
int ksnf=intf-20;
int jsnf=intf;
string stmp1="";
for(int i=ksnf;i<jsnf;i++)
{
stmp1=i.ToString();
ListItem list=new ListItem();
list.Text=stmp1;
list.Vlaue=stmp2;
DropDownList .Items.Add(list);
}
stmp2 的声明和值在哪?
for(int i=2007;i<year;i++)
{
listiem list=new listitems(i,i);
dropdownlist.items.add(list);
}
for(int i=2007;i <years;i++)
{
listiem list=new listitems(i,i);
dropdownlist.items.add(list);
}
ListItem list = new ListItem();
list.Text = DateTime.Now.Year.ToString();
list.Value = DateTime.Now.Year.ToString();
dropdownlist.Items.Add(list);
{
//在页面加载时调用这个方法
AddYear();
// 为了验证VALUE被绑定,写一小段脚本验证一下
dropYear.Attributes.Add("onchange", "document.getElementById('lblYear').innerText=document.getElementById('dropYear').value");
} //做一个添加年份的方法
protected void AddYear()
{
//年份从当前年开始,到多少自己决定
for (int i = DateTime.Now.Year; i >= 1900;i-- )
{
//new ListItem中第一个参数为显示的数据,第二个是绑定的VALUE
dropYear.Items.Add(new ListItem(i.ToString(),i.ToString()));
}
}
界面中
string strYear = System.DateTime.Now.Year;
int year = Convert.ToInt32(strYear );
for(int i=2007;i <year;i++)
{
this.DropDownList.Items.Add(strYear );
this.DropDownList.Items[this.DropDownList.Items.Count - 1].Value = strYear ;
this.DropDownList.SelectedIndex = this.DropDownList.Items.Count - 1;
}
Me.ComboBox1.Items.Add(i)
Next i