J
~john
I'm adding a DropDownList to my page in the code behind which is set to
AutoPostBack... The problem is it's giving me the same SelectedValue on
every post back, the value of the first item in the list... The
DropDownList itself retains the correct selected value (the option I
select in the list is the option the dropdown list retains on postback
-but- the property "SelectedValue" is always the first item in the list
for some reason and not the value that I selected from the
DropdownList. any ideas?
protected void Page_Load(object sender, EventArgs e)
{
DropDownList DropDownList_EquipmentTypes = new DropDownList();
DropDownList_EquipmentTypes.ID = "myList";
DropDownList_EquipmentTypes.DataSource =
ObjectDataSource_EquipmentTypes;
DropDownList_EquipmentTypes.DataTextField =
"EquipmentTypeDesc";
DropDownList_EquipmentTypes.DataValueField = "EquipmentTypeID";
DropDownList_EquipmentTypes.DataBind();
DropDownList_EquipmentTypes.AutoPostBack = true;
PlaceHolder1.Controls.Add(DropDownList_EquipmentTypes);
//This value is always the first item in the list and not the
value selected????
string x = DropDownList_EquipmentTypes.SelectedValue;
}
AutoPostBack... The problem is it's giving me the same SelectedValue on
every post back, the value of the first item in the list... The
DropDownList itself retains the correct selected value (the option I
select in the list is the option the dropdown list retains on postback
-but- the property "SelectedValue" is always the first item in the list
for some reason and not the value that I selected from the
DropdownList. any ideas?
protected void Page_Load(object sender, EventArgs e)
{
DropDownList DropDownList_EquipmentTypes = new DropDownList();
DropDownList_EquipmentTypes.ID = "myList";
DropDownList_EquipmentTypes.DataSource =
ObjectDataSource_EquipmentTypes;
DropDownList_EquipmentTypes.DataTextField =
"EquipmentTypeDesc";
DropDownList_EquipmentTypes.DataValueField = "EquipmentTypeID";
DropDownList_EquipmentTypes.DataBind();
DropDownList_EquipmentTypes.AutoPostBack = true;
PlaceHolder1.Controls.Add(DropDownList_EquipmentTypes);
//This value is always the first item in the list and not the
value selected????
string x = DropDownList_EquipmentTypes.SelectedValue;
}