I have an asp dropbox which I populate from database:
this is the aspx
<asp:DropDownList runat="server" ID="ddl_last" AppendDataBoundItems="true">
and this is the cs:
ddl_last.DataSource = eggsContext.Customers;
ddl_last.DataValueField = "last_name";
ddl_last.DataTextField = "last_name";
ddl_last.DataBind();
When I try to get ddl_last.SelectedValue from the c# code I get nothing. infact ddl_last.Items count is 0! When I don't populate it from code, but write in the aspx
<asp:ListItem Text="example" />
everything works.
I can get the value from javascript by writing document.getElementById('ddl_last').value;
But I was wondering what did microsoft screw up this time that this is not working from the code behind?