G
Guest
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"],
"ExtSchID");
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"],
"DMVExpirationDate");
txtDOTReg.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"],
"DOTRegistration");
dtpDOTExp.DataBindings.Add("VALUE", dsVehicle.Tables["VehDetail"],
"DOTExpirationDate");
VListing.CurrentRowIndex = 0;
{
if ((!Loading) && (txtVYear.Text.Length>0))
dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]["Year"] =
txtVYear.Text.ToString();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if(dsVehicle.HasChanges(DataRowState.Modified))
{
conVeh.Open();
sdaVehicle.Update(dsVehicle, "VehDetail");
conVeh.Close();
}
SaveMsg = false;
this.Close();
}
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"],
"ExtSchID");
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"],
"DMVExpirationDate");
txtDOTReg.DataBindings.Add("Text", dsVehicle.Tables["VehDetail"],
"DOTRegistration");
dtpDOTExp.DataBindings.Add("VALUE", dsVehicle.Tables["VehDetail"],
"DOTExpirationDate");
VListing.CurrentRowIndex = 0;
{
if ((!Loading) && (txtVYear.Text.Length>0))
dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]["Year"] =
txtVYear.Text.ToString();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if(dsVehicle.HasChanges(DataRowState.Modified))
{
conVeh.Open();
sdaVehicle.Update(dsVehicle, "VehDetail");
conVeh.Close();
}
SaveMsg = false;
this.Close();
}