Custom item value resets after binding the ComboBox in C# -


i have raddropdownlist (telerik component combobox), in application bind database table items into.

public static void bindcombobox(raddropdownlist cb, string displaymember,                                         string valuesmember, string sql) {             connect = new sqlceconnection(connectionstring);             sqlcedataadapter da = new sqlcedataadapter(sql, connect);             system.data.dataset ds = new system.data.dataset();             da.fill(ds);             da.dispose();             cb.datasource = ds.tables[0];             ds.dispose();             cb.displaymember = displaymember;             cb.valuemember = valuesmember;             cb.selectedvalue = null; } 

after binding items in combobox, add item it:

radlistdataitem item = new radlistdataitem {text = "all", value = 0}; cmb.items.add(item); cmb.selecteditem = item; 

but when select new item in combobox , check selected value, it's empty (not null).

what happens value set item before adding list?

update

i found out cmb.selecteditem = item; doesn't work , selecteditem remains null after running line.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -