asp.net中的日期格式问题 [英] date format problem in asp.net

查看:69
本文介绍了asp.net中的日期格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友下午好,
我已经将dropdownlist与method绑定了(该方法在dropdownlist中显示日期和时间的方式是这样的
(9/5/2012 12:00:00 am,9/12/2012 12:00:00 am,9/21/2012 12:00:00 am 10/5/2012 12:00:00 am,10/5 /2012 12:00:00 am和11/25/2012 12:00:00 am,11/30/2012 12:00:00 am)
我想显示在下拉列表中,例如
九月,十月,十一月等……..
下拉列表中仅显示一个月

good afternoon friends,
i have bind dropdownlist with method(the method display date and time in dropdownlist like this
(9/5/2012 12:00:00am,9/12/2012 12:00:00am,9/21/2012 12:00:00am 10/5/2012 12:00:00am,10/5/2012 12:00:00am and 11/25/2012 12:00:00am,11/30/2012 12:00:00am)
i want to display in dropdownlist like
September,October,November and so on.............
only single month will be display in dropdownlist

DropDownList.DataTextField = "StartDate"


请帮我一些提示或链接

如果我们一个月中有两个或两个以上日期,则仅对所有月份显示一次
添加了您的代码,使用改进问题


please help me some hints or links

if we have two or more dates in a month only single month display for all
Added you code, use improve question

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
{
vt.TAuthOccuList dlocc = new vt.TAuthOccuList();
dlocc = ab.GetWebOccurrencesForProgrammeAndDates(Session["token"].ToString(), Convert.ToInt32(Session["ddldate"].ToString()), DateTime.Now, DateTime.Now.AddMonths(8)); DropDownList2.DataSource = dlocc.OccuList; DropDownList2.DataValueField = "occur_id"; DropDownList2.DataTextField = "StartDate"; DropDownList2.DataBind();
}

推荐答案

我不确定我是否正确理解了您的要求.
如果您希望在下拉列表中显示月份列表,则可以如下所示添加它们

I am not sure if i understood your requirement correctly.
If you want a list of months to be displayed in the drop down you can just add them as shown below

<asp:DropDownList ID="ddlMonths" runat="server">
    <asp:ListItem Text="January" Value="1"></asp:ListItem>
    <asp:ListItem Text="Febuary" Value="2"></asp:ListItem>
    <asp:ListItem Text="March" Value="3"></asp:ListItem>
    <asp:ListItem Text="April" Value="4"></asp:ListItem>
    <asp:ListItem Text="May" Value="5"></asp:ListItem>
    <asp:ListItem Text="June" Value="6"></asp:ListItem>
    <asp:ListItem Text="July" Value="7"></asp:ListItem>
    <asp:ListItem Text="August" Value="8"></asp:ListItem>
    <asp:ListItem Text="September" Value="9"></asp:ListItem>
    <asp:ListItem Text="October" Value="10"></asp:ListItem>
    <asp:ListItem Text="November" Value="11"></asp:ListItem>
    <asp:ListItem Text="December" Value="12"></asp:ListItem>
    </asp:DropDownList>


这篇关于asp.net中的日期格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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