GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 367 of 436    Print  
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

  
Total Answers and Comments: 6 Last Update: June 13, 2008     Asked by: Nitesh 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Tina
 
We can use the AcceptChanges() method.

Above answer was rated as good by the following members:
Loki117
October 04, 2006 16:13:02   #1  
Asghar Malik        

RE: We have a dataset with one thousand records. Now w...
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
 
Is this answer useful? Yes | No
October 05, 2006 01:06:21   #2  
Sachin Rastogi        

RE: We have a dataset with one thousand records. Now w...

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.


 
Is this answer useful? Yes | No
October 29, 2006 01:08:17   #3  
Jianhua        

a

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()

 
Is this answer useful? Yes | No
November 03, 2006 14:34:50   #4  
Tina        

RE: We have a dataset with one thousand records. Now w...
We can use the AcceptChanges() method.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 29, 2007 06:12:56   #5  
manish sinha        

RE: We have a dataset with one thousand records. Now w...
Use dataset.GetChanges() method to return a modified copy of the dataset. This dataset will have only 3 records modified ones.
 
Is this answer useful? Yes | No
June 13, 2008 09:16:57   #6  
Max Headroom Member Since: June 2008   Contribution: 1    

RE: 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
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...
}

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape