We have a dataset with one thousand records. Now we bind it to a datagrid. Now the question is suppose we have modified only three records in datagrid then how to update these three records in dataset. We have a single button to update the records

Showing Answers 1 - 10 of 10 Answers

Asghar Malik

  • Oct 4th, 2006
 

If the dataset is necessary to update then first we should take the primary key from grid and then update ine dataset by comparing the primary key

  Was this answer useful?  Yes

Sachin Rastogi

  • Oct 5th, 2006
 

If we have a dataset. in our database first we find the primary key field and the field store in an Array  and update using these  values.

  Was this answer useful?  Yes

Jianhua

  • Oct 29th, 2006
 

first, when you have edit a cell and moved to another ROW, data is automatically transferred to the binding dataset.

Second, if you really want to do that, call myBindingResource.EndEdit()

  Was this answer useful?  Yes

Tina

  • Nov 3rd, 2006
 

We can use the AcceptChanges() method.

manish sinha

  • Jun 29th, 2007
 

Use dataset.GetChanges() method to return a modified copy of the dataset. This dataset will have only 3 records, modified ones.

  Was this answer useful?  Yes

Use the RowState property of the DataTable in the DataSet that the grid is bound to where RowState is Modified. You can do this in a number of ways, if you do a Select on the DataTable you can pass RowState as one of the parameters of the overloaded Select methods this will return an array of Row Objects of only the modified rows. 

foreach(DataRow ModifiedRow in _MyDT.Select(string.Empty
                                                                         ,string.Empty
                                                                         ,DataViewRowState.Added))
{
    Do update here...
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions