M
mark4asp
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.Value)
lblConsultantName.Text = ddlConsultant.Items.Text ;
Or is there an another way?
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.Value)
lblConsultantName.Text = ddlConsultant.Items.Text ;
Or is there an another way?