[thelist] ASP.NET - Logic in Data Grids?

Gary McPherson lists at ingenyus.net
Thu Oct 7 17:54:56 CDT 2004


----Original Message----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Casey Crookston
Sent: 07 October 2004 22:45
To: thelist at lists.evolt.org
Subject: [thelist] ASP.NET - Logic in Data Grids?

> OK - Thank you in advance for all of this help as I still try
> to get my feet wet with ASP.Net.  From what I can tell, the
> classic recordset idea does not exist in .net.  So I'm learning about
> Data Grids. 
> 
> Here's my question.  Client wants to display a list of
> events.  All events are coming from the same db table.  They
> want to split the display into upcoming and past events.  In
> classic ASP I would have used the cursor in the recordset to
> split future and past events (simple if then on the date
> field).  What's the best way to do it in a data grid?  Are
> there any logic controls built into this grid?  Or should I
> use two separate queries from the start?
> 
> Thanks,
> 
> Casey
> 
> P.S.  Programming in vb.net

Hi Casey.

You appear to be confusing two ASP.NET objects with similar names, but very
different purposes. The DataSet is the replacement for the old ADO
Recordset, while a DataGrid is a server control which allows data, from a
wide variety of sources (including a DataSet) to be displayed in the manner
you described above.

The functionality you've described above is definitely achievable with a
DataGrid, but the way in which you approach it is completely different from
traditional ASP. Roughly put, you would:

1. Fill a DataSet with your database query
2. Modify the ItemDataBound event to check for past or future events and
modify the display accordingly (changing background colour, font weight,
however you're doing it)
3. Set the DataSet as the DataSource for the DataGrid
4. Execute the DataGrid's DataBind method to load it with the data in the
DataSet
5. Sit back and enjoy. :)

There are TONS of articles and tutorials regarding DataGrids and DataSets,
you should definitely spend some time reading those and any pertaining to
general differences between ASP and ASP.NET, just to get yourself more
accustomed to the new way of doing things.

Hope that helps,

Gary




More information about the thelist mailing list