GridView vs DataGrid

G

GaryDean

I liked the DataGrid because I was familiar in walking through it to do
custom filling and retrieval of data in cases where standard binding
wouldn't do the job.

I read somewhere that the object model is the same for the datagrid and the
gridview. But as I begin to try to manually load a gridview I notice that
there is no such thing as a GridViewItem as there was a DataGridItem. So,
it's not the same.

Are there any articles or tutorials on how to walk through, and build
Gridviews in code?
 
G

GaryDean

Those are some interesting things but I'm looking for help on manually
loading and retrieving data from cells and controls inside the cells. It
seems to be a whole different object model than the datagrid was.
 
W

Walter Wang [MSFT]

Hi Gary,

Thank you for your post.

To understand why we introduce the new GridView control while DataGrid is
doing pretty good, we need to address two points:
1) While DataGrid is one of the most powerful controls in ASP.NET 1.x, it
requires too much work for mundane tasks such as sorting, paging, sorting,
and deleting data.
2) ASP.NET 2.0 enhances the data-binding architecture, introducing a new
family of components--the data source objects, which act as a bridge
between data-bound controls and ADO.NET objects. The familiar DataGrid
control is still supported, but it doesn't take full advantage of the
specific capabilities of data source components.

You can find more information at here:

#GridView: Move Over DataGrid, There's a New Grid in Town!
http://msdn.microsoft.com/msdnmag/issues/04/08/GridView/

In my opinion, if your purpose is to manually load and retrieve data from
cells and controls inside the cells, I would recommend you still use the
DataGrid control, it's still supported in ASP.NET 2.0. If you want to try
the new and powerful data-binding feature of data source objects (such as
SqlDataSource, ObjectDataSource), I would recommend you use the GridView
control.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

James Thomas

DataGridItem in the DataGrid is analogous to the GridViewRow in the
GridView, accessed like this:
foreach (GridViewRow gvr in GridView1.Rows) {
// Do whatever
}

Hope that helps.

James
 
G

GaryDean

Walter, (I know it's been a while since your post :)

I'm interested in why you recco still using the datagrid for manual walking
through. Does it somehow have advantages over the gridview?

I'm thinking of basing some new components using this functionality and if I
base them on the DataGrid I would hate to see support dropped for it in the
reasonable future.
 
W

Walter Wang [MSFT]

Hi Gary,

I'm sorry if I've misled you in my last post. I recommended you still use
the DataGrid for the manually loading data into cell because you've said
that you're already familiar with it, :)

Of course I will recommend you use GridView if you're writing new project,
especially using features such as sorting, paging, etc.

Have a nice day!


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top