Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ComboBox resetting to original value when datarow.endedit() is called

Posted on 2004-09-02
13
Medium Priority
?
563 Views
Last Modified: 2012-06-27
I have a combobox on a form that has it's text property bound to a dataset and it's itemcollection is entered through the form designer.   When I change the value in the combo box the dataset is not getting updated with the new value.   Therefore when I call the dataadapter update function the changes aren't updated in the database.

I've tried using the beginEdit() and endEdit() functions on the datarow and that doesn't work.   As soon as the endEdit() is called the combobox reverts back to it's original value.

Any help is appreciated.    Thanks.
0
Comment
Question by:jeff411
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
13 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11965189
Shouldn't  the selectedItem be bound instead of the text ?
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11965210
Also what type is the bound column, the text returns a string, if the underlaying field is numeric it will fail aswell
0
 
LVL 1

Author Comment

by:jeff411
ID: 11966636
The field it is bound to is a string and I've tried selectedItem, selectedValue, Text and every combination of the three.   The dataset never gets updated because it doesn't think there are changes in that field.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:jeff411
ID: 11966945
I have added CType(dsCurrentRMA.RMA.Rows(0), dsRMA.RMARow).Status = cbRMAStatus.Text to write the value directly to the dataset before calling the endEdit function.   This seems to update the database fine now, but that's more like a work around and I'm still interested in a solution to this problem.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11970664
Hi jeff411,

Could you post some code. Because I've tried to recreate your problem and the only way I can recreate it is if I try to update right after changing the combobox. If I change record or field than it should work.

RB
0
 
LVL 1

Author Comment

by:jeff411
ID: 11972325
RonaldBiemans,

I have been updating the combobox and then calling update.    So what you are saying is that if I change the combobox and then change a field the combobox will update, but if I just change the combobox it won't?
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11972350
Yes, because if you haven't moved from the combobox it doesn't know that it has changed. But if you give me a minute maybe I have a solution for that.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11972422
Hi Jeff411,

before you update do something like this

        Me.BindingContext(yourdatasource).EndCurrentEdit()

yourdatasource should be your dataset or datatable which you use to bind to the text of your combobox

so if you did something like this

        ComboBox1.DataBindings.Add("Text", dataset.tables(0), "test")

do

        Me.BindingContext(dataset.tables(0)).EndCurrentEdit()
0
 
LVL 1

Author Comment

by:jeff411
ID: 11976624
Here is my onload function.   What I'm doing is taking the RMA datarow from the dataset where they opened the RMA from and importing it into the RMA details form; saving me from having to wait to fill another dataset.

        dsCurrentRMA.Clear()
        dsCurrentRMA.RMA.ImportRow(frmForm.DsRMA1.RMA.Select("RMANumber = " + CStr(m_recordIndex))(0))
        Me.BindingContext(dsCurrentRMA.RMA).Position = 0
        dsCurrentRMA.RMA.Rows(0).BeginEdit()

Here is my Save function ( on button click )

            dsCurrentRMA.RMA.Rows(0).EndEdit()
            dbcomp.UpdateRMA(dsCurrentRMA)
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11988527
Hi Jeff411,

Then try this before the update and see if it works

Me.BindingContext(dscurrentrma).EndCurrentEdit()
 dbcomp.UpdateRMA(dsCurrentRMA)
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 2000 total points
ID: 11988537
maybe this it better

Hi Jeff411,

Then try this before the update and see if it works

Me.BindingContext(dscurrentrma.rma).EndCurrentEdit()
 dbcomp.UpdateRMA(dsCurrentRMA)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question