如何通过在下拉列表中循环来设置值字段 [英] How can i set value field by looping in drop down list
本文介绍了如何通过在下拉列表中循环来设置值字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hii,
private void BusinessYearMonthAndDateDropDown()
{
DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance( null );
for ( int i = 1 ; i < 13 ; i ++)
{
drpBusinessStartMonth.Items.Add( new ListItem(info.GetMonthName(i),i.ToString()));
}
for ( int i = 1 ; i < = 31 ; i ++)
{
drpBusinessStartDate.Items.Add(i.ToString());
}
}
这是我的代码..执行此代码存储datavalue字段属性。如果我将moths添加到我的列表中..我可以将其value属性设置为1到12 ..如果不能如何在我的代码中设置它?
解决方案
< blockquote>是的,您的代码也设置了listitem的值。请访问以下链接,了解您实际所做的事情: http://msdn.microsoft.com/en -us / library / 7f7h2h8h.aspx [ ^ ]
hii,
private void BusinessYearMonthAndDateDropDown()
{
DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null);
for (int i = 1; i < 13; i++)
{
drpBusinessStartMonth.Items.Add(new ListItem(info.GetMonthName(i), i.ToString()));
}
for (int i = 1; i <= 31; i++)
{
drpBusinessStartDate.Items.Add(i.ToString());
}
}
This is my code.. does this code stores datavalue field property . if i am adding moths into my list .. can i get its value property as 1 to 12 as well .. if not how can i set that in my code?
解决方案
Yes your code is setting the value of the listitem as well. Visit the following link for details about what you are actually doing: http://msdn.microsoft.com/en-us/library/7f7h2h8h.aspx[^]
这篇关于如何通过在下拉列表中循环来设置值字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文