Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid / dataset.haschanges questions

Status
Not open for further replies.

amberlynn

Programmer
Dec 18, 2003
502
CA
Hello,
I'm unsure on how best to do this:

I have a datagrid, bound to a dataset.
I use if dataset1.haschanges - save datagrid data.
But this doesn't work if there is no data in the dataset (which is common).
So if no data exists (the datagrid is blank) and the user type a row of data, dataset1.haschanges still returns false.

How do I get around this?
Thanks,
Amber
 
you can count the number of records in your dataset and see if it's different than when it was first loaded:

Code:
private function getNumberOfRecord(myDataSet as dataset) as integer

dim i as integer = 0

for each table as datatable in mydataset.tables
i += table.rows.count
next

return i

end function
 
But if the dataset.haschanges doesn't work, because the original dataset never fills - counting the records will return zero before and after I've added a row to the datagrid...won't it?
Otherwise wouldn't .hasChanges return true?

TIA :)
Amber
 
What about adding
dataset1.AcceptChanges
when user change any row of the dataset1?

mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top