|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to query the key and value pair in ComboBoxfrom the combobox (e.g., "Martin"), how can I access the value of that item (e.g., "1")? Thank you, DD Dim dtAdjuster as new DataTable dtAdjuster.Columns.add("Names") dtAdjuster.Columns.add("Keys") dtAdjuster.loaddatarow(new object() {"Martin", "1"},true) dtAdjuster.loaddatarow(new object() {"Cor","2"},true) 'This can all in probably hundred other ways, this is the way I do it. Combobox1.datasource = dt Combobox1.displaymember = "Names" Combobox1.Valuemember = "Keys"
Show quote
Hide quote
> I am using the following code as an example. Once the user selects an Combobox1.SelectedValue.ToString> item from the combobox (e.g., "Martin"), how can I access the value of > that item (e.g., "1")? > > Dim dtAdjuster as new DataTable > dtAdjuster.Columns.add("Names") > dtAdjuster.Columns.add("Keys") > dtAdjuster.loaddatarow(new object() {"Martin", "1"},true) > dtAdjuster.loaddatarow(new object() {"Cor","2"},true) > > 'This can all in probably hundred other ways, this is the way I do it. > > Combobox1.datasource = dt > Combobox1.displaymember = "Names" > Combobox1.Valuemember = "Keys" I tried that, it is returning "System.Data.DataRowView" as the value of the
item. What is wrong? Any idea? Show quoteHide quote "Jim Wooley" wrote: > > I am using the following code as an example. Once the user selects an > > item from the combobox (e.g., "Martin"), how can I access the value of > > that item (e.g., "1")? > > > > Dim dtAdjuster as new DataTable > > dtAdjuster.Columns.add("Names") > > dtAdjuster.Columns.add("Keys") > > dtAdjuster.loaddatarow(new object() {"Martin", "1"},true) > > dtAdjuster.loaddatarow(new object() {"Cor","2"},true) > > > > 'This can all in probably hundred other ways, this is the way I do it. > > > > Combobox1.datasource = dt > > Combobox1.displaymember = "Names" > > Combobox1.Valuemember = "Keys" > > Combobox1.SelectedValue.ToString > > > |
|||||||||||||||||||||||