Last post Sep 09, 2009 06:18 PM by pixelsyndicate
Sep 09, 2009 05:25 PM|cmt9000|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 05:48 PM|MetalAsp.Net|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 05:50 PM|pixelsyndicate|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 06:11 PM|cmt9000|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 06:18 PM|pixelsyndicate|LINK
myListBox.Items.Add(new ListItem("textgoeshere", "valuegoeshere"));