c# - add item and fill DropDownlist from db -


add ---select--- item , fill dropdownlist db

 if (cboassignto != null)  {          getusers();          cboassignto.datasource = getactiveusers(dstauthusrlist).tables[0];          listitem lstitm = new listitem("new", "");          cboassignto.items.insert(0, lstitm); } 

i set proterty appenddatabounditems true , add 1 empty value

.aspx

<asp:dropdownlist id="cboassignto" runat="server" appenddatabounditems="true" >      <asp:listitem value="" text=""></asp:listitem> </asp:dropdownlist> 

then can bind data

.cs

cboassignto.datasource = getactiveusers(dstauthusrlist).tables[0]; cboassignto.databind(); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -