Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-02
13
Medium Priority
?
567 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
11 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

877 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