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
Solved

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

Posted on 2004-09-02
13
536 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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