Europleethept
New Member
Is it possible to somehow set and reference an alternate index on a dropdownlist or listbox control? Whereas before I would have a select box with options that had values, so I could refence that value, now I'd like to do the same kind of thing with a dropdownbox, but the values don't match the index that is automatically assigned. Do I just have to use a select?<BR><BR>Here's what I want in my drop down:<BR><BR>(1) Store<BR>(2) District<BR>(4) Division<BR>(9) Chain<BR><BR>Where the parenthesis indicate what I would like the index values to be but not show up on the ddlist. I know I can do this in VB6 as well, but the same methods aren't there in .Net. Any help is appreciated.<BR><BR><BR><BR><BR><BR><BR>Are you just trying to add a value to the drop downbox..<BR><asp
ropDownList ID="xxx" Runat="server" AutoPostBack="True" ><BR><asp:ListItem Value=http://aspmessageboard.com/archive/index.php/aaa>xxxx</asp:ListItem><BR><asp:ListItem Value=bbb>xxxx</asp:ListItem><BR><asp:ListItem Value=ccc>xxxx</asp:ListItem><BR></asp
ropDownList>Well, I was trying to do it in the page load sub:<BR><BR>Do While sdr.Read()<BR> ddlLevels.Items.Add(sdr("Level")<BR> 'Is there a method that sets the value of the item I just added?<BR><BR>LoopC# is<BR>ddlLevels.Items.Add(sdr["Level"],sdr["levelTEXT"])<BR>i think vb.net would be<BR>ddlLevels.Items.Add(sdr("Level"),sdr(levelTEXT"))<BR><BR>I think that will work..Actually.. I this is it...<BR>var2.DataValueField = s.ToString(); var2.Items.Add(s.ToString());You set the value by create a ListItem and then adding that ListItem.<BR><BR>ListItem liItem = new ListItem("value", "string");<BR>ddlSelect.Items.Add(liItem);<BR>Sorry it is<BR>ListItem liItem = new ListItem("string", "value");<BR>Perfect, thanks!!

