|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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... |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
Are you doing this in ASP or VB?
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 ![]() |
|
#6
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Binding comboboxes to two datasets? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|