David D. McCrory wrote:
This is the second post for this question....ple ase help!!
This is a fairly simple request....I am looking for some help....
I want to set the SelectedIndex of a DataList control to equal a specific
record in the database. What is the easiest way to accomplish this??
Thanks,
David D. McCrory
I would add a handler for the ItemDataBound event of the DataList and
then the event args give you access to the current item and its data.
e.Item.DataItem gives the current item in the datasource; use this to
check for a certain value
e.Item.ItemInde x gives the current item's index
I believe you can set the selectedindex in this event; if not, set a
local/member var to the value and then after the DataBind, set it.
The other solution is to loop the items after the DataBind instead of
using the event, but doing the first way does one less loop.
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET