Click here to Skip to main content
16,018,529 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
in a form there are two drop down list they filled with month name, i use this code to fill the fill drop down list ..in page load..
C#
if (!IsPostBack)
         {
              for (int i = 4; i >=1; i--)
              {
                  string Month = (Convert.ToDateTime("01/" + i.ToString("00") +"/"+ DateTime.Now.Date.ToString("yyyy"))).ToString("MMM");
                  ddlFromMonth.Items.Insert(0, new ListItem(Month,i.ToString()));
              }
              FillToMonth();


And second dropdown filles with this code


C#
private void FillToMonth()
       {
           ddlToMonth.Items.Clear();
           for (int i = Convert.ToInt32(ddlFromMonth.SelectedValue)+5; i >= Convert.ToInt32(ddlFromMonth.SelectedValue); i--)
           {
               string Month = (Convert.ToDateTime("01/" + i.ToString("00") + "/" + DateTime.Now.Date.ToString("yyyy"))).ToString("MMM");
               ddlToMonth.Items.Insert(0, new ListItem(Month, i.ToString()));
           }

how i fill girdview according to January to march, April to june, july to sep, oct to Dec.while we choose value in drop down list
Posted
Updated 15-Sep-12 1:31am
v3
Comments
sreekanthv12 15-Sep-12 8:06am    
Pass the value of dropdownlist to gridview. it will display according to the value of dropdownlist.
FIROZ KHANIT 15-Sep-12 8:17am    
how can u explane in details .
vinod deo from navi mumbai 17-Sep-12 8:30am    
Hi Firoz , Is there is any Specific Data which need to be bind to Grid, based on the Months range that you are going to select from the above dropdonwlists ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900