Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
Hello all,
I have one dataset which populating from xml file and has below stucture.

{Id},{Name},{Amount}

I want to
1) Update name and amount in this dataset for particular id
2) Delete record which has particular id from dataset
3) Insert new record in dataset if particular id is not present in dataset.


Please let me know the code.
Posted

That shouldn't be a problem, see Updating Existing Records in a Dataset[^]

Cheers,
Edo
 
Share this answer
 
Use .select method in datatable. The parater for this method is a string. You can specify the filter condition here. The filtered records will be come as Data Row collection. From that collection you can update any record. if no records for your criteria u can directly add that row into the datatable.
 
Share this answer
 
Comments
RDBurmon 6-May-13 8:19am    
Thank you. I understood first part.
Could you please explain me below statement using code ?
"From that collection you can update any record. if no records for your criteria u can directly add that row into the datatable."
Raja Soosai 7-May-13 5:32am    
For updating existing row:

modify the filtered row collection by looping each row and each column.

Add a new row:

If no record found for your critetia then as per requirement, you can create a new row and add it into the same data table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900