i have create a dropdownlist.
after that i have create a userdefined method
i want to bind the system month and year in this format in the dropdownlist when the page is load
format is Oct-13 this is current month
then next month it will bind like Nov-13
then next month Dec-13
then next Jan-14
like that . plz give me the complete solution
Thanx
Sanjeeb LenkaPosted Oct 24, 2013, 3:19 AM
try this method: call this in pageload
private void PopulateMonth()
{
ddlMonth.Items.Clear();
ListItem lt = new ListItem();
lt.Text = "Select";
lt.Value = "0";
ddlMonth.Items.Add(lt);
string curyear=DateTime.Now.Year.ToString();
for (int i = 1; i <= 12; i++)
{
lt = new ListItem();
lt.Text = Convert.ToDateTime(i.ToString()+"/1/" + curyear).ToString("MMM-yy");
lt.Value = i.ToString();
ddlMonth.Items.Add(lt);
}
ddlMonth.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
}
ranjan sahooPosted Oct 24, 2013, 4:25 AM
Sanjeeb LenkaPosted Oct 24, 2013, 3:58 AM
ranjan sahooPosted Oct 24, 2013, 3:46 AM
ranjan sahooPosted Oct 24, 2013, 1:48 AM
Pankaj KumarPosted Oct 23, 2013, 9:44 AM
http://aspsnippets.com/Articles/Select-Day-Month-and-Year-Date-from-DropDownList-in-ASPNet.aspx
Jaganathan BantheswaranPosted Oct 23, 2013, 9:28 AM
ddlist.Items.Add(date);
ranjan sahooPosted Oct 23, 2013, 5:53 AM
string date= String.Format("{0:MMM-yy}", Date);
but how to insert it into dropdownlist item?
Jaganathan BantheswaranPosted Oct 23, 2013, 5:28 AM
ranjan sahooPosted Oct 23, 2013, 5:02 AM
Jaganathan BantheswaranPosted Oct 23, 2013, 2:10 AM
Don't post same question again and again. The original post is here & it is answered.