?
Solved

Updating a DataTable in Memory?

Posted on 2009-04-13
1
Medium Priority
?
281 Views
Last Modified: 2012-06-27
Experts,

All the lit I've read on updating a bound DataTable talk about mapping the "UpdateMethod" property to a method that will take parameters from the grid and then updating the actual database table.  In other words, the update goes right to the table instead of to the DataTable object.  I don't want to write to the database when the user is adding quantities to items in his/her order.  I want to update in memory and then once the user is finished, update that object to a database.

Is this possible?
0
Comment
Question by:NigelRocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
philipjonathan earned 2000 total points
ID: 24134516
Yes. First, you need to get the DataRow to be updated. For this you need to have some kind of key or identification. An example:
DataRow[] rows = dtTable.Select("ID = 10");
DataRow rowToUpdate = null;
if ((rows != null) && (rows.Count > 0))
  rowToUpdate = rows[0];

OR, if you have initialised the PrimaryKey property of that DataTable:

DataRow rowToUpdate = dtTable.Rows.Find(10);

Second, update the columns accordingly:
rowToUpdate["GivenName"] = "John";
rowToUpdate["FamilyName"] = "Doe";
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question