Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 09, 2009 05:18 PM by pixelsyndicate
Sep 09, 2009 04:25 PM|LINK
I have a listBox on my web form that allows users to select multiple userNames from it.
However, in order to save those selected user names to a database, I need the userID.
Is there a way of "hidding" the userID in the listBox or would I need to use another type of web form element?
Sep 09, 2009 04:48 PM|LINK
A listbox allows you to specify a text & value. The text is what gets displayed and the value you set to whatever you want, say userID in your case.
Sep 09, 2009 04:50 PM|LINK
ListItem's in a listbox or dropdownlist or anything like that can have two values.
the VALUE (which the user doesn't see) should be the UserID
the TEXT of the items should be what the user can see and understand, like the UserNames.
<asp:ListBox ID="myListBox" runat="server">
<asp:ListItem Text="JobBob" Value="123"></asp:ListItem></asp:ListBox>
Sep 09, 2009 05:11 PM|LINK
I don't see a way to add a value...this is what I have:
If dr.HasRows Then
Do While dr.Read
Could I do myListBox.Add.Value(dr.Item("userID")?
Sep 09, 2009 05:18 PM|LINK
myListBox.Items.Add(new ListItem("textgoeshere", "valuegoeshere"));