F
Fred Sawtelle
I have a DropDownList which is databound on first page
load to a dataview, and which has its AutoPostback set to
true (yes, this is necessary). For each item in the
list, the text is either a department name or an alias
for a department, and the value is a DeptID. Departments
and their respective aliases have the same DeptID in the
value field.
My DropDownList appears to be saving its SelectedValue in
the ViewState for server trips. I thought it would be
SelectedIndex. But I have found that when an item is
selected which shares its value with other items, the
first item alphabetically by text field is the one
selected after a server trip.
For example, an item may have a value of 20 and a text
of "Regular Department Name", and another item may have a
value of 20 and a text of "Alias Department Name". If I
select "Regular Department Name" in the list, it performs
its AutoPostback, and when the page loads it sets itself
to "Alias Department Name". However, if I
preface "Regular" with "AAA" (making it first
alphabetically), it doesn't do this. If I
preface "Alias" with "RRR" (making it second
alphabetically), it doesn't do it.
I've seen this behavior with several different examples.
The simple explanation would be that it's just looking
for the first occurrence of its SelectedValue and setting
SelectedIndex to that.
I need it to remember the actual SelectedIndex. I should
mention that this control is part of a server control
that is rendered in a portal, and its name has been
randomly changed by the time it makes it to HTML at the
client, so getting the SelectedIndex from Request.Form is
not an option.
Any help with this would be appreciated.
Fred Sawtelle
load to a dataview, and which has its AutoPostback set to
true (yes, this is necessary). For each item in the
list, the text is either a department name or an alias
for a department, and the value is a DeptID. Departments
and their respective aliases have the same DeptID in the
value field.
My DropDownList appears to be saving its SelectedValue in
the ViewState for server trips. I thought it would be
SelectedIndex. But I have found that when an item is
selected which shares its value with other items, the
first item alphabetically by text field is the one
selected after a server trip.
For example, an item may have a value of 20 and a text
of "Regular Department Name", and another item may have a
value of 20 and a text of "Alias Department Name". If I
select "Regular Department Name" in the list, it performs
its AutoPostback, and when the page loads it sets itself
to "Alias Department Name". However, if I
preface "Regular" with "AAA" (making it first
alphabetically), it doesn't do this. If I
preface "Alias" with "RRR" (making it second
alphabetically), it doesn't do it.
I've seen this behavior with several different examples.
The simple explanation would be that it's just looking
for the first occurrence of its SelectedValue and setting
SelectedIndex to that.
I need it to remember the actual SelectedIndex. I should
mention that this control is part of a server control
that is rendered in a portal, and its name has been
randomly changed by the time it makes it to HTML at the
client, so getting the SelectedIndex from Request.Form is
not an option.
Any help with this would be appreciated.
Fred Sawtelle