943,712 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 1806
  • C# RSS
Jul 6th, 2009
0

Changing label text from dataset

Expand Post »
I have a combo box which is in set to be a drop down list. How do I change the label text based on which ID is selected in the combo box. How do I make the label text change to the corresponding row as the ID?

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
functionalCode is offline Offline
32 posts
since May 2009
Jul 6th, 2009
0

Re: Changing label text from dataset

I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Jul 6th, 2009
0

Re: Changing label text from dataset

Click to Expand / Collapse  Quote originally posted by wildgoose ...
I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.
If I have a list of Names in the dataset and each have an ID and I have a combo box that displays the list of IDs. If I click an ID how to I get the label to show the name corresponding to that ID that was selected from the combobox.

Thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
functionalCode is offline Offline
32 posts
since May 2009
Jul 6th, 2009
0

Re: Changing label text from dataset

You click a listbox or combobox, it returns the index of that item.
You use that index to get the name, or the user data value.

Not the other way around!
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Jul 6th, 2009
0

Re: Changing label text from dataset

DataRow[] rows = yourTable.Select(string.Format("ID='{0}'",cbIDs.Text));

yourLabel.Text = (string)rows[0]["Name"];
Last edited by JerryShaw; Jul 6th, 2009 at 9:00 pm.
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006
Jul 6th, 2009
0

Re: Changing label text from dataset

Thanks guys! That should help me.
Reputation Points: 10
Solved Threads: 0
Light Poster
functionalCode is offline Offline
32 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: pass selected gridview row to another gridview on another page
Next Thread in C# Forum Timeline: How to open a new forum on its own thread





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC