Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: DropDownList and Data Tables


Message #1 by "F-J Mattmann" <f-j.mattmann@e...> on Fri, 18 Oct 2002 13:43:36
hi
I have a Datatable (table1) which has 2 columns: "Name" and "USER-ID"
now I want to present the Names field in a DropDown-list (which I succeed 
with)
but I want then to fetch the rows of an other DataTable (Table2) which has 
3 columns: "USER-ID" "Address" "Telefon" 
which correspond with the selected Table1.name (and USER-ID of course) 
that correspond to the Table2.User-ID
I know how to refer to the selected.Item of my DropDownList with:

namechoice = DropDownlist_name.selectedItem


but how kan I get the value of the associated "USER-ID" of my choice 
so that I kan fetch the corresponding rows from my Table2

------
Thank you for any help!

//F-J
Message #2 by Jcriv@a... on Mon, 21 Oct 2002 17:44:53 EDT
Each item in a dropdown list can have two 'values' associated with it.  
'text' and 'value'.  The 'text' appears in the control but you can retrieve 
either the 'text' or the 'value'.  In VB you can do something like

ddlNames.Items.Add(New ListItem("Joe Smith", "12345"))

where Joe Smith is the 'text' field and appears on the control list and  
'12345' coule be your ID Number.  You can retrieve the ID Number

IdNum = ddlNames.SelectedItem.Value

Hope that helps.
John Ritchie


  Return to Index