lblConsultantName.Text =ddlConsultant.Items.FindByValue
(hidConsultantID.ToString()).Text;
Is it what you are after?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin http://usableasp.net
"mark4asp" <mark4asp@gmail.comwrote in message
news:1173098639.637914.138990@30g2000cwc.googlegro ups.com...
Quote:
Is it possible to treat values and items of a DropDownList like a
HashTable?
>
My page records the value of the ConsultantName in a label
lblConsultant and the ID in a hidden field hidConsultantID
>
If I know the value of the ID: hidConsultantID, how do I lookup the
corresponding name, given that I have a DropDownList which maps
corresponding ConsultantIDs to their Names for the consultant
(ddlConsultant, IDs are values and names are shown as text)?
>
Must I need to loop through each item?
>
for (int i = 0; i < ddlConsultant.Items.Count; i++)
if (hidConsultantID.ToString() == ddlConsultant.Items[i].Value)
lblConsultantName.Text = ddlConsultant.Items[i].Text ;
>
Or is there an another way?
>