I am very new to C# and .Net. I may be overlooking something very simple here, however, even after reading several forums I'm still stumped.
I can't get the HasChanges method to work. It always returns false.
I have a dataset on the form (DSCustRow), which is loaded by a different class.
My binding seems to work as the data appears on the form.
When I press the save button, I check for changes on the dataset.
The result is always false. I can move off the field, tab around, update multiple fields and the result is always the same; HasChanges is always false. From other entries, I tried adding AcceptChanges prior to checking with no luck.
I've read other forums on this problem, but the solutions did not work for me.
Thank you very much in advance,
MF
(DSCustRow is defined as a dataset on the form.)
Expand|Select|Wrap|Line Numbers
- private void CustomerDetail_Load(object sender, EventArgs e)
- {
- DBCustomer ldb = new DBCustomer();
- if (this.strInCustSysid.Length > 0)
- {ldb.CustSysid = this.strInCustSysid;}
- DataTable dt = ldb.GetCustomerData();
- this.DSCustRow.Tables.Add(dt);
- this.CUST_SYSID_PK.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_SYSID_PK");
- this.CUST_NAME.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_NAME");
- this.CUST_ADDR_LINE1.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_ADDR_LINE1");
- this.CUST_ADDR_LINE2.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_ADDR_LINE2");
- this.CUST_CITY.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_CITY");
- this.CUST_STATE.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_STATE");
- this.CUST_POSTAL.DataBindings.Add("Text", this.DSCustRow,
- "CUSTOMER.CUST_POSTAL");
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- int x; // for testing
- if (DSCustRow.HasChanges())
- {
- x = 5; //never gets here.
- }
- }