By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Dotnet Combox Datasource

P: 13
how to read the valuemember of the combox whose data source is a detaset. i have assigned the properties of displaymember and valuemember . display member cis visible but i cant get the value member behind it..........
Sep 13 '07 #1
Share this Question
Share on Google+
2 Replies


dip_developer
Expert 100+
P: 648
how to read the valuemember of the combox whose data source is a detaset. i have assigned the properties of displaymember and valuemember . display member cis visible but i cant get the value member behind it..........
suppose customer_name is displaymember and customer_id is valuemember ...........
you can have it by..........

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim custid As String =CType(cmyCombo.SelectedValue,String)
  3.  
if valuemember is not set.....then you can have it by .........

Expand|Select|Wrap|Line Numbers
  1.  Dim custid As String = CType(myCombo.SelectedItem, DataRowView).Row("customer_id ")
Sep 13 '07 #2

Plater
Expert 5K+
P: 7,872
Sometimes (as is the case with a dataset)
the SelectedValue property returns an entire Row instead of just what is defined as the "valuemember".
You could check this by saying:
Expand|Select|Wrap|Line Numbers
  1. MessageBox.Show(mycombobox.SelectedValue.GetType().Name);
  2.  
That will tell you the name of the object it is returning, which frequently sheds some light on the problem.
Sep 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.