method to bind ListBox, DropDownList, RadioButtonList

  • Thread starter Thread starter kids_pro
  • Start date Start date
K

kids_pro

I tried to create a simple method to bind 3 kind of control

private void SimpleBinding(ListControl lc, string tblName, string txtField,
string valField){
SqlDataReader dr = ....
//... get value from database

lc.DataTextField = txtField;
lc.DataValueField = valField;
lc.DataBind();
}
-- call method:
SimpleBinding(DropDownList1,"Employee","FullName","EmployeeID");

There is no error but the value not bind to the control.

Did I do something wrong?
How to create a method to handle this sort of binding?

Many thanks,
Kids
 
Back
Top