?
Solved

DataGrid and Batch Update in ASP.NET

Posted on 2004-09-16
5
Medium Priority
?
361 Views
Last Modified: 2012-06-27
Sir,

In ASP.NET, I want to display number of records with many column and Edit many records and many columns.  After my edit I  want to update all the edited records in one click.  When I check with ASP.NET, I have to edit one record, update it and then go for another record.  I don't want to do like this.  Is it possible to Edit and Update Many records at a time? (Like Batch Update)  Please advise me in this matter.  

Thanks
0
Comment
Question by:adwat
[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
  • 2
5 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 12078152
Yes, it is:

First of all, you have to use a Dataset rather than a DataReader or Repeater.  The Dataset is what will keep track of your changes before you fire them off to the database as a batch.  You will need to create a data adapter with a select command and an update command that will either Fill your datatable or Update it when you have made all your changes.  Then when you make changes to data in a row in your grid, you will save those changes to the underlying dataset.  Once all changes have been made, you call the data adapter's Update() method (likely in the click event of a button) and the data adapter recognizes which rows of data were changed and fires the update command SQL for these rows.

The only challenge with this is it taxes the viewstate.  The only way to make it work reasonably is to use paging on the grid to keep the amount of data viewstate has to keep down to a manageable level.  But when the user navigates to another page in the grid, the Update() method has to be called for the previous page to save any changes.

If you need help putting these things together, I'd be happy to help.

John
0
 
LVL 33

Accepted Solution

by:
raterus earned 2000 total points
ID: 12078558
jnhorst, I don't see why you couldn't do this with a datalist/repeater...

adwat,
As for the actual changes you need to make to the DataGrid, you need to forget about the "Edit" capabilities of the datagrid on this one.  Rather make each itemtemplate a templatecolumn, and use textboxes (or any other form control you want to use), then define an "Update" button, and when you click that you'll have to loop through each of the items of the datagrid and get the changes, then plug that into what jnhorst said.
0
 
LVL 10

Expert Comment

by:jnhorst
ID: 12149421
Raterus is correct.  I incorrectly lumped DataReader with Repeater/DataList.  This can certainly be done done with a Repeater/DataList.  It should just be bound to a data table in a dataset.

John
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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