Dataset doesn't return true when dataset datarow has been modified

Dataset doesn't return true when dataset datarow has been modified

Post by QWxwaG » Fri, 04 Nov 2005 06:36:02

Hi, I have a window C# application. I update the dataset when user finished
entering in a text box. But when I want to update the database when OK is
pressed, the if(dsVehicle.HasChanges(DataRowState.Modified)) would return
false and update of the dataset would take place. I do notice that if I
select other item that the textbox is bind to then the modified indicator
would then return true. Is there any code that I can add in the private void
txtVYear_Validated(object sender, System.EventArgs e) to indicate the dataset
row has been changed myself?

Thanks, Alpha

cmbScheudle.DataSource = dsSchedule.Tables["Schedule"];
cmbScheudle.DisplayMember = "ScheduleName";
cmbScheudle.ValueMember = "SchID";

//bind all the editable textboxes
cmbScheudle.DataBindings.Add("SelectedValue", dsVehicle.Tables["VehDetail"],
txtVName.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "VName");
txtVIN.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "VIN");
txtVYear.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "Year");
txtVMaker.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "Make");
txtVModel.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "Model");
txtDMV.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"], "DMVLicense");
dtpDMVExp.DataBindings.Add("VALUE", dsVehicle.Tables["VehDetail"],
txtDOTReg.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"],
dtpDOTExp.DataBindings.Add("VALUE", dsVehicle.Tables["VehDetail"],
VListing.CurrentRowIndex = 0;

if ((!Loading) && (txtVYear.Text.Length>0))
dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]["Year"] =

private void btnOK_Click(object sender, System.EventArgs e)
sdaVehicle.Update(dsVehicle, "VehDetail");
SaveMsg = false;

Dataset doesn't return true when dataset datarow has been modified

Post by Pete Davi » Sat, 05 Nov 2005 01:17:25

I think all you need to do is call CurrencyManager.EndCurrentEdit() prior to
doing the HasChanged check.

You'd basically do:


You may have to do it for the individual PropertyManager for the particular
TextBox that last had the focus. I'm not sure. I'm really just taking a stab
in the dark here. I haven't done much with binding controls other than grid
style controls.

I'm not positive your changes will get pushed to the dataset prior to the
EndCurrentEdit, though. Anyway, give these a try and if neither of these
work, I'll try to come up with another option.