Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, ALL

C#
strQry = "select CodeC from ShiftLite";
DataTable dt2 = new DataTable();
dt2 = DbCon.GetData(strQry);
DropDownList1.DataSource = dt2;
DropDownList1.DataTextField = "CodeC";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0,new ListItem("--SELECT--",""));



here i want same fields which i retrieve from database i want to display multiple dropdownlist like DropDownList2, DropDownList3,DropDownList4, DropDownList5

Is there any way to get easly

thanks you !
Posted

 
Share this answer
 
Comments
prasanna.raj 17-Sep-14 7:17am    
Thank you for your advice...
Create one function with 4 args
C#
PopulateDropDown(DropDownList ddl,DataTable dt,string displayField,string defaultText){
            ddl.DataSource = dt;
            ddl.DataTextField = displayField;
            ddl.DataBind();
            DropDownList1.Items.Insert(0,new ListItem(DefaultText,""));
}
 
Share this answer
 
v2
Comments
prasanna.raj 17-Sep-14 5:43am    
so i want to use like this na...

PopulateDropDown(arg1,arg2,arg3,arg3);PopulateDropDown(arg1,arg2,arg3,arg3);PopulateDropDown(arg1,arg2,arg3,arg3);PopulateDropDown(arg1,arg2,arg3,arg3) if i have 4 dropdownlist.

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