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 LenkaRank #301 · 8.3K reputationPosted Oct 23, 2013, 11:19 PM EDT
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;
}
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 22, 2013, 10:10 PM EDT
Don't post same question again and again. The original post is here & it is answered.
ranjan sahooRank #5,709 · 289 reputationPosted Oct 23, 2013, 1:02 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 23, 2013, 1:28 AM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 23, 2013, 1:53 AM EDT
string date= String.Format("{0:MMM-yy}", Date);
but how to insert it into dropdownlist item?
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 23, 2013, 5:28 AM EDT
ddlist.Items.Add(date);
Pankaj Kumar198 reputationPosted Oct 23, 2013, 5:44 AM EDT
http://aspsnippets.com/Articles/Select-Day-Month-and-Year-Date-from-DropDownList-in-ASPNet.aspx
ranjan sahooRank #5,709 · 289 reputationPosted Oct 23, 2013, 9:48 PM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 23, 2013, 11:46 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Oct 23, 2013, 11:58 PM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 24, 2013, 12:25 AM EDT