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