用下拉列表将日期与数组值绑定 [英] bind date with dropdownlist with array value
问题描述
hiii朋友,
我在dropdownlist中有一些问题绑定日期
日期通过日期时间格式的数组项来,但我想绑定dropdownlist
喜欢
一月
二月
三月
四月
等等...
如何找到这样的日期
2012年3月1日,2012年5月1日,2012年15月1日至1月,
2012年3月2日,2012年5月1日,2012年15月2日进入2月
2012年3月25日,2012年3月23日进入三月
如何在数组中查找所有日期并绑定dropdownlist
jan
2月
三月
等等
hiii friends,
i have some issue binding date into dropdownlist
the date is coming through array items like datetime formats but i want to bind dropdownlist
like
January
February
march
April
and so on......
how to find date like this
3/1/2012,5/1/2012,15/1/2012 into January,
3/2/2012,5/1/2012,15/2/2012 into February
25/3/2012,23/3/2012 into March
how to find all dates in array and bind dropdownlist
jan
feb
march
and so on
推荐答案
hiii,
您的示例代码为
hiii,
Your Sample Code is
string[] standardToolBoxArray = new string[5] { "String1", "String2", "String3", "String4", "String5" };
DropDownList1.DataSource = standardToolBoxArray;
DropDownList1.DataBind();
我刚把数组放在循环中
然后更改日期格式
然后
过滤下拉列表
i have just array put on loop
and then change the format of date
and then
the filter the dropdownlist
试试看:
string[] Months = new string[MyArray1.Items.Count]{};
int i = 0;
foreach(var date in MyArray1){
Month[i] = (Convert.ToDateTime(date)).ToString("MMMM");
i++;
}
DropDownList1.DataSource = Months;
DropDownList1.DataBind();
--Amit
--Amit
这篇关于用下拉列表将日期与数组值绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!