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
Post a Comment