Hi,
I know these aren't new server controls, but this was the most appropriate forum I found. Is anyone else having a problem with using these controls programmatically? My specific example is as follows:
I am populating a DropDownListBox with the following code:
protected
void Page_Load(object sender, EventArgs e)
{
ddlRoles.DataSource = Roles.GetAllRoles();
ddlRoles.DataBind();
//other code after this
}
and then accessing the control to get the role selected by the user using the following code:
protected
void btnCreateUser_Click(object sender, EventArgs e)
{
string selectedRole = ddlRoles.SelectedValue;
//other code after this
}
The roles I have created using the website configuration tool are "Administrator" and "Agent" and they both appear in the DropDownListBox ddlRoles, but ddlRoles.SelectedValue will only ever return "Administrator". Do I need to do some ViewState stuff here perhaps for it to remember the value of the ListBox, or why isn't it returning the correct selected value?
Thanks a lot,
Eddie