views:

900

answers:

4

I've got to present a spreadsheet-style interface with a grid of textboxes for the user to fill in in an ASP.NET application. What's the most efficient way to construct this and to save the results?

A: 

Will it have a fixed number of rows?

If the user doesn't have to insert new rows, but only needs to fill in or modify existing cells, then the GridView might be the appropriate control to use.

If you don't have a fixed number of rows (i.e the user can add and remove rows) then the ListView class would be the path to follow. With regards to saving it's the same model - a user commits (or saves) on a row-by-row basis.

With regards to saving the results, it would depend on whether you are saving to flat file or database. ASP.NET provides a number of datasource objects that you can plug into the GridView or ListView.

The MSDN has a number of walkthroughs on this.

Andrew Shepherd
Do I iterate the rows in the gridview on save, or is there a way to commit the records in a batch?
Caveatrob
+1  A: 

If you need a ton of control over what the users can do with the grid, I like to create DataGrid tables where each column is a TemplateColumn. This way I can choose how each TextBox binds, and I have full control over how to save the data, whether it be row by row or the entire matrix at once.

If you're interested in seeing code, comment on this and I'll try to whip something up.

Cory Larson
I would LOVE to see some code on this!!!
tbone
A: 

This extension of the MS GridView looks promising:

Bulk Edit with GridView without xxxDataSource (SqlDataSource, ObjectDataSource, etc.) http://www.codeproject.com/KB/webforms/BulkEditGridView.aspx

tbone
A: 

Hi,

 I use gridview in asp.net. gridview display 10 records per page i have save button on each row while i am clicking the save button the particular row getting inserted.while i am clicking the save all button then i need to save all the 10 records i need code for save all button any body have idea about it
nirmaladevi