Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2004, 09:50 AM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get data from datagrid in the form datatabl

Hi

In our application, we have editable datagrid, user can update edit multiple rows at once. When user clicks on save button, all the records should be updated simultaneously. On save button we want to use datatable/dataset apporach that is on click of save we want all records from grid in the form Datatable/Dataset for data we written following statement on save button click event:
DataTable dt = dgViewHedge.DataSource as DataTable;
but we got null in dt variable.
Basically our approach is to save all data in once. We want to pass datatable/dataset to dataadapter so it updates at once.

Is there any way, we can get all data from grid in the form of DataTable or Dataset.

With Regards

Sunder Ramani
 
Old January 7th, 2005, 12:22 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The datasource property of the datagrid is only useful during the binding stage of your page. When you load the datatable, assign it to grid.DataSource, then bind. After page postbacks, the DataSource property will be null. The datagrid maintains the data internally without aid of the original data source. So you'll need to do one of two things:
1) Reload the datatable, then iterate thru the datagrid items and set the corresponding datatable values from the datagrid controls then call the datatable update method.
2) make simple database update calls for each row in the datagrid without using a datatable object. (That's what the data adapter is doing internally anyway when you provide it a datatable with changed rows and an UpdateCommand object.)
 
Old January 10th, 2005, 12:08 AM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks. I had implemented Incorporated your suggestion.

But what should be the best way to update data in a web application?
1) Row by Row ?
2) All data at once?



 
Old January 12th, 2005, 03:59 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In most of the web applications I've worked on, I update one row of data or one set of related data at a time so I make simple SQL update/insert calls.

If you build a grid that is completely editable then you could loop thru all its items and do a bulk update.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlit the new data over the old data in DataGrid kotanaresh_2003 ASP.NET 1.0 and 1.1 Basics 0 April 12th, 2007 10:26 PM
Using Datagrid...getting data on separate form Renu Classic ASP Databases 4 August 7th, 2004 09:52 PM
DataEntry form and DataGrid joblot VB How-To 0 May 5th, 2004 12:16 AM
DataGrid(Windows Form) shiju VS.NET 2002/2003 1 November 1st, 2003 11:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.