Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I written the function as follows

private void dropdownfill(DropDownList Dname)
{

Dname.Items.Clear();
Dname.Items.Add("--Select Grading--");
Dname.Items.Add("Excellent");
Dname.Items.Add("Very Good");
Dname.Items.Add("Good");
Dname.Items.Add("Fair");
Dname.Items.Add("Poor");

}

Then i have three dropdownlist as follows

Dropdownlist1
Dropdownlist2
Dropdownlist3

in the above 3 Dropdownlist i want the Grading as follows

Excellent
Very Good
Good
Fair
Poor

For Example Dropdownlist1 as follows

Dropdownlist1 ("Excellent")
("Very Good")
("Good")
("Fair")
("Poor")


for that how can i do in asp.net using csharp.

Regards,
Narasiman P.
Posted
Comments
Vishal Pand3y 12-Nov-13 7:11am    
can u explain this line for that how can i do in asp.net using csharp.
Do you want to show the values serially?

1 solution

Hi Narasiman,

I tried some code for your requirement, try this
C#
public void Page_Load(object sender, EventArgs e)
       {
           List<string> strVal=new List<string>();
           strVal.Add("Excellent");
           strVal.Add("Good");
           strVal.Add("Super");
           strVal.Add("Average");
           strVal.Add("Bad");
           BindDDLValue(strVal,DropDownList1);
           BindDDLValue(strVal, DropDownList2);
           BindDDLValue(strVal, DropDownList3);
       }

       private void BindDDLValue(List<string> listVal, DropDownList ddl)
       {
           if (ddl != null)
           {
               ddl.DataSource = listVal;
               ddl.DataBind();
           }
       }

Which will apt to your requirement I believe. try this and lemme know.
You can pass any number of dropdown control to the method it will bind and give it back to you.

Regards,
RK
 
Share this answer
 
v2
Comments
Kalpana M 12-Nov-13 9:39am    
You should use IsPostback in Load event. Isn't?
♥…ЯҠ…♥ 12-Nov-13 9:45am    
Its working for binding as per requirement.

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