here you can bind threee dates , today date and tomrrow date, and day after tomorrow dates to drop down list.
here we have to use namespace using System.Globalization;
.aspx page code :
.cs page code
here we have to use namespace using System.Globalization;
.aspx page code :
<table width="300" border="0" cellspacing="1" cellpadding="7">
<tr>
<td>
<asp:DropDownList ID="DdlDATE"
runat="server"
Height="23px"
Width="233px"
AutoPostBack="True">
<asp:ListItem Selected="True"
Value="0">--Select
Date--</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
.cs page code
protected void Page_Load(object
sender, EventArgs e)
{
if
(!IsPostBack)
{
ListItem lt = new ListItem();
lt.Text = "--Select
Date--";
lt.Value = "0";
DdlDATE.Items.Add(lt);
String
sDate = DateTime.UtcNow.ToString();
DateTime
datevalue = (Convert.ToDateTime(sDate.ToString()));
string
pattern = CultureInfo.CurrentCulture.DateTimeFormat.MonthDayPattern;
pattern = pattern.Replace("MMMM", "MMM");
string
formatted = "Today, " +
datevalue.ToString(pattern);
string
formatted1 = "Tomorrow, " +
datevalue.AddDays(1).ToString(pattern);
string
formatted2 = datevalue.AddDays(2).ToString(pattern);
DdlDATE.Items.Add(formatted);
DdlDATE.Items.Add(formatted1);
DdlDATE.Items.Add(formatted2);
}
}
No comments:
Post a Comment