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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AcceptChanges in datagrid with multiple rows

Status
Not open for further replies.

sheykc

Programmer
Sep 28, 2001
79
US
I have a datagrid that has many editable fields on the grid. When the user is done, they click save and it updates all the rows. The dataset is populated via a stored procedure. This all works great.

The problem I have now, is when they click on the "Add Items" box to add a new row to the table, and if they didn't save their changes to the page first before adding the new row, they lose the changes.

I was wanting to do something like "AcceptChanges" before it adds the new row of information, but when I check the rowstate of rows I have edited in the datagrid, it always says unchanged.

I've tried to check the viewstate of the dataset and also the dataset itself to see the new values but they never appear. Am I looking at the wrong thing? (dsPricing is a declared at the beginning of the class)

Code:
Dim _NewDataRow As DataRow
  dsPricing.AcceptChanges()
  _NewDataRow = dsGrid.Tables(0).NewRow
  _NewDataRow("CapsContractItemID") = 0
  _NewDataRow("BillToNum") = strBillToNum
  _NewDataRow("DeleteItemFlag") = 0
  _NewDataRow("ShowItemFlag") = 1
  dsPricing.Tables(0).Rows.InsertAt(_NewDataRow, 0)
  dsPricing.AcceptChanges()

 'rebind ds to datagrid
  grdPricing.DataSource = dsPricing
  grdPricing.DataBind()
 
Where is this code being called from? Also, how are you doing the multiple updates?

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top