在“下拉列表"框中增加值 [英] Increment the value in Drop Downlist box

查看:106
本文介绍了在“下拉列表"框中增加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我想在3个不同的下拉列表框中显示天,月和年.
如果在ASP中,我将使用VB脚本和for循环在天数"字段中将值从1递增到30.
但是,现在我在ASP.Net中工作,请建议是否可以自动增加天数,或者我必须将值从1硬编码为30.

Dear Friends,

I want to display Days, Months and Year in 3 different Drop Downlist box.
If it is in ASP, I will increment the value from 1 to 30 in Days Field using VB Script and for loop.
But now I am working in ASP.Net, Kindly suggest is there provision to auto increment the days or I have to hardcode the values from 1 to 30.

推荐答案

此处是类似的线程.
for下拉列表框中的循环吗? [
Here is a similar thread.
for loop in dropdownlist box ?[^]




在ASP.NET中,您也可以执行相同操作.

在页面加载功能中尝试一下

Hi,

In ASP.NET also you do the same.

try this in Page Load function

//dropdownlist1 display days
if(!IsPostBack)
{
 dropdownlist1.Items.Clear();

 for(int i=1;i<=30;i++)
 {
    dropdownlist1.Items.Add(new ListItem(i,i));
 }

}



希望它能起作用.



Hope it works.


这篇关于在“下拉列表"框中增加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆