Hiiiiii
I have some problem for binding month year in drop downlist in dynamically?
I want to bind month and year in this format
example:- Oct-13
and when the next month will come then bind like this Nov-13
plz help thanx
Loading

Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 22, 2013, 3:55 AM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 22, 2013, 4:04 AM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 22, 2013, 4:09 AM EDT
Gomathi PalaniswamyRank #714 · 3.3K reputationPosted Oct 22, 2013, 4:29 AM EDT
You could split the date and combine it in string.
Else,try this
string date= String.Format("{0:MMM/yy}", Date);
use date in binding drop down.It;s working for me.
Thanks
Gomathi
ranjan sahooRank #5,709 · 289 reputationPosted Oct 22, 2013, 4:36 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 22, 2013, 5:42 AM EDT
Try like this,
// Get the en-US culture.
CultureInfo ci = new CultureInfo("en-US");
// Get the DateTimeFormatInfo for the en-US culture.
DateTimeFormatInfo dtfi = ci.DateTimeFormat;
var months = dtfi.AbbreviatedMonthGenitiveNames;
for(int i=13; i< 20; i++)
{
for (int j = 0; j< months.Length-1; j++)
{
ddl_date.Items.Add(string.Format("{0}-{1}", months[j], i);
}
}
ranjan sahooRank #5,709 · 289 reputationPosted Oct 22, 2013, 9:07 PM EDT
ranjan sahooRank #5,709 · 289 reputationPosted Oct 22, 2013, 9:14 PM EDT
after that i have create a 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 code
Thax
ranjan sahooRank #5,709 · 289 reputationPosted Oct 23, 2013, 2:04 AM EDT
// Get the en-US culture. CultureInfo ci = new CultureInfo("en-US");
// Get the DateTimeFormatInfo for the en-US
culture. DateTimeFormatInfo dtfi = ci.DateTimeFormat;
var months = dtfi.AbbreviatedMonthGenitiveNames;
for(int i=13; i< 20; i++)
{ for (int j = 0; j< months.Length-1; j++)
{ ddl_date.Items.Add(string.Format("{0}-{1}", months[j], i); } }