how to populate asp:DropDownList from C# side

Ambinkknono

New Member
I am trying to populate asp:DropDownList with data items and here is the code i have written so far.aspx side\[code\]<asp:DropDownList ID="ddl" runat="server" />\[/code\]C# side\[code\]protected void btnAdd_Click(object sender, EventArgs e){ ddl.DataTextField = "hello"; ddl.DataTextField = "2"; ddl.DataBind();}\[/code\]The method \[code\]btnAdd_Click\[/code\] is invoked. I tested it. But the data list is not getting populated with those data items.
 
Back
Top