DataValueField - postback

M

Mike

I haven't been able to find any posts about this problem.
When I set the DataValueField to be something, the control
loses it's selected index when returning from the
postback. If I set only the DataTextField I have no
problems.

I set the DataTextField and DataValueFields like so:

ddlBU.DataTextField="BU"; -- each value is unique
ddlBU.DataValueField = "ORG_ID"; -- is 1 of 2 values

It seems that the because Org_Id is not unique in the
dataset it is screwing up the index of the control by
setting the SelectedIndex to be the first ListItem it
finds with a DataValueField matching that of the
originally selected item.

Anyone know of a work around ?
 
A

Alvin Bruney

why don't you manually set the selected item to the value of the item you
are looking for
selectedindex = 9; for 10th item
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top