Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ok, should be simple, but i'm having a hard time getting this to work. I have a combo box that is populated with the following.

 

da.Fill(ds, "Subscription");
cboSubscriptions.DataSource = ds.Tables["Subscription"];
cboSubscriptions.DisplayMember = "SubscriptionNo";
cboSubscriptions.ValueMember = "SubscriptionID";

Value Member         DisplayMember
1                            2323235235
2                            3352525233
3                            4564564564
etc....

 

This works fine but once the combo box is populated is where i'm having my trouble. I'm getting some values out of a database table that have the 'SubscriptionID' in it. How can I take the database value and then have the combo box selected based off of that value.

 

If i'm pulling a subscriptionID of '2' out of the database, i need to set the combo box to show 3352525233.

 

thanks.

Posted

Try doing it this way

 

da.Fill(ds, "Subscription");

cboSubscriptions.DisplayMember = "SubscriptionNo";

cboSubscriptions.ValueMember = "SubscriptionID";

cboSubscriptions.DataSource = ds.Tables["Subscription"];

 

I dont no exactly why but i already got that problem and solved it by defining first the display member and the value member.

Posted

hmm. not quite my problem. let me try and re-explain. I am populating a combo box from a table called subscriptions. This table has 'subscriptionID' and 'subscription' in the table. I'm putting the 'subscriptionID' field in the combo box value member and putting the 'subscription into the display member.

 

Once that is loaded, i'm pulling a record out of a table that contains 'softwareID', 'softwareName', 'binderID', 'subscriptionID'. I need to make the dropdown box be selected to the value of subscriptionID from this table. Basically, if the record I pull out of the second table has a 'subscriptionID' of 2, then the dropdown box needs to be on the item that has the valuemember of 2.

 

Does that make sense?

 

thanks so far for the help!!

Posted

You mean like this..

 

bob.SelectedIndex = bob.Items.IndexOf("subscriptionID")

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...