ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 31st, 2003, 10:18 PM
csharpener csharpener is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 3 csharpener User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Binding comboboxes to two datasets?

Hi can any one help with this?

I have a dataentry form for adding,deleting and editing client records. On the form there are 5 comboboxes that need to load their contents from lookup tables in a database. The information selected in them is added to the current client record and should reflect the value in the client record when editing. This seems like it should be simple however, I can only seem to successfully bind the comboboxes to one thing at a time... ie. if I am adding a record they work as they are supposed to but if I am editing a record they wont show what was already in the client record. One of the comboboxes is related to another - eg. a region combobox value is selected which populates the area combobox. Apart from that it is all very straight forward...

Any ideas on what the problem may be or where to start looking for answers would be appreciated muchly

Cheers...

Reply With Quote
  #2  
Old May 2nd, 2003, 07:42 PM
SalimMorgan SalimMorgan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 SalimMorgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Double Binding Combo Boxes`

Well, I've got the opposite result where it works fine for edits but not for adds done by doing AddRow to the dataset. I bound to the lookup table using DataSource, DisplayMember and ValueMember. Then, I bound to the other recordset by binding the Value to a field in the master dataset. Like you, I thought this should be really simple, the the data from the added row never shows in the controls. If you get any answer, PLEASE e-mail me at URL. Also, it might help if you describe exactly what you did to get the opposite result from what I got.

Reply With Quote
  #3  
Old May 3rd, 2003, 09:22 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Are you doing this in ASP or VB?

Reply With Quote
  #4  
Old May 3rd, 2003, 01:34 PM
SalimMorgan SalimMorgan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 SalimMorgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Two-Ended Binding

ASP.NET using C#. I think I figured it out. Text boxes can be bound to dataset columns and it works fine in both directions. Loading a record fills the text boxes correctly and changing them changes the dataset ready for update without any intervention.

Lookups are a different story. For example combo boxes which look up from another table, display a string and keep a value internally. Here, you do four things.

data source = lookupdataset name
display member = tablename.namefieldname (within lookupdataset)
value member = tablename.codefieldname

Then, under "Data Binding"
selected value <binds to> maindataset.tablename.fieldname

This last thing is just "one way" binding. In other words, when you load the dataset, it will position the combo box correctly accoring to the key value, but changing the selectedindex by moving the current row in the DB does not automatically update the dataset. Confusing at first. Thus, right before saving, you have to move all the values from the combo boxes (but not the textboxes) into the appropriate fields in the dataset like the below:

dsChem1.Chem.Rows[0]["UseID"] = Convert.ToInt32(cbUse.SelectedValue);

The documentation speaks about "one way" binding and "two way" binding and makes statements like "depending on how you set it up", but I have not found anywhere where you actually have the choice.

Reply With Quote
  #5  
Old May 3rd, 2003, 09:46 PM
csharpener csharpener is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 3 csharpener User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

Hi... sorry for the lack of replies to this thread but I found a workaround similar to SalimMorgan's...

This question came up while developing a Windows Application and the control was actually a Windows.Forms.ComboBox set to DropDownList mode... apparently when you set the mode to List or DropDown you don't strike the same problems - the symptoms are mentioned here DotNetBugs (when its working!)
Thanks all for your comments

Reply With Quote
  #6  
Old May 4th, 2003, 10:05 AM
SalimMorgan SalimMorgan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 SalimMorgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Combo Box Binding

Mine is and always has been in "DropDown" mode. Choices are "Simple", "DropDown" and "DropDown List". And yet, I am definitely having this problem. I haven't tried the other two choices. I'm not so sure its a bug, maybe just half-baked design.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Binding comboboxes to two datasets?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT