ASP Migration - Moving Through DataSets

D

Don Miller

In my migration from ASP to ASP.NET 2.0, I have a fair number of complicated
HTML tables that defy anything .NET can do. Using classic ASP I created
these tables (by string concatenation) by moving forward, and at times,
backward through a recordset (using a static cursor rather than a
forward-only cursor).

I can't seem to find any methods in .NET to move to a previous row in a
Dataset (e.g. MovePrev, MoveFirst). Am I trying to use the wrong object to
navigate through rows of data returned from a database query? Is there a
better way?

Thanks for any direction.
 
E

Eliyahu Goldin

To answer your question, a Dataset contains a collection of DataTables. A
DataTable contains a collection of Rows. You can use just an integer index
to navigate through it.

Generally speaking, asp.net is object-oriented, not procedure-oriented.
Several server controls, such as repeater, datalist and gridview, can
produces a databound html table with item (row) structure of any complexity.
Trying using asp.net in the classic asp way won't be productive and will be
always annoying you. Something like driving an airplane instead of flying
it.
 
D

Don Miller

Thanks. I forgot entirely about integer indexes.

I appreciate your comments about the difference between the two platforms.
What I have found so far for HTML tables with ASP.NET they are "simply"
grids with one row representing one row of data albeit with ability to have
hyperlinks, formatting, etc.. My HTML tables may have several display lines
("rows") for just one row of data, that flex to two or three columns per
page of "rows" that are several display lines, all sorted by groups. I just
have not seen anything created with ASP.NET that comes even close.

I would love to see examples of how to do similar things with .NET
(something like below). Thanks again

(Typical .NET GridView)
Column 1 Header Column 2 Header Column 3
Row1Column1Data Row1Column2Data Row1Column3Data
Row2Column1Data Row2Column2Data Row2Column3Data
Row3Column1Data Row3Column2Data Row3Column3Data

(what I need)
Custom Header1 Custom Header3
Row1Column1Data Row3Column1Data
Row1Column2Data Row3Column2Data
Row1Column3Data Row3Column2Data

Custom Header2
Row2Column1Data
Row2Column2Data
Row2Column3Data


Eliyahu Goldin said:
To answer your question, a Dataset contains a collection of DataTables. A
DataTable contains a collection of Rows. You can use just an integer index
to navigate through it.

Generally speaking, asp.net is object-oriented, not procedure-oriented.
Several server controls, such as repeater, datalist and gridview, can
produces a databound html table with item (row) structure of any
complexity. Trying using asp.net in the classic asp way won't be
productive and will be always annoying you. Something like driving an
airplane instead of flying it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Don Miller said:
In my migration from ASP to ASP.NET 2.0, I have a fair number of
complicated HTML tables that defy anything .NET can do. Using classic ASP
I created these tables (by string concatenation) by moving forward, and
at times, backward through a recordset (using a static cursor rather than
a forward-only cursor).

I can't seem to find any methods in .NET to move to a previous row in a
Dataset (e.g. MovePrev, MoveFirst). Am I trying to use the wrong object
to navigate through rows of data returned from a database query? Is there
a better way?

Thanks for any direction.
 
E

Eliyahu Goldin

Datalist is capable of arranging several items in a row. You can make an
item template containing a table with one column and 3 rows and databind the
cell in the first row to column 1 etc. The item template can also include an
html for the header, also databound if needed. In this way arrangement
Item1 Item2
Item3
is implemented with no problems.

For arrangement
Item1 Item3
Item2
you would probably need to re-order the rows in the dataset to bring it to
the first case.

Even if you don't want to use item templates, you can build an html table
dynamically out of server html controls for table, row and cell. It would be
still better than concatenating html elements to a string.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Don Miller said:
Thanks. I forgot entirely about integer indexes.

I appreciate your comments about the difference between the two platforms.
What I have found so far for HTML tables with ASP.NET they are "simply"
grids with one row representing one row of data albeit with ability to have
hyperlinks, formatting, etc.. My HTML tables may have several display lines
("rows") for just one row of data, that flex to two or three columns per
page of "rows" that are several display lines, all sorted by groups. I just
have not seen anything created with ASP.NET that comes even close.

I would love to see examples of how to do similar things with .NET
(something like below). Thanks again

(Typical .NET GridView)
Column 1 Header Column 2 Header Column 3
Row1Column1Data Row1Column2Data Row1Column3Data
Row2Column1Data Row2Column2Data Row2Column3Data
Row3Column1Data Row3Column2Data Row3Column3Data

(what I need)
Custom Header1 Custom Header3
Row1Column1Data Row3Column1Data
Row1Column2Data Row3Column2Data
Row1Column3Data Row3Column2Data

Custom Header2
Row2Column1Data
Row2Column2Data
Row2Column3Data


Eliyahu Goldin said:
To answer your question, a Dataset contains a collection of DataTables. A
DataTable contains a collection of Rows. You can use just an integer index
to navigate through it.

Generally speaking, asp.net is object-oriented, not procedure-oriented.
Several server controls, such as repeater, datalist and gridview, can
produces a databound html table with item (row) structure of any
complexity. Trying using asp.net in the classic asp way won't be
productive and will be always annoying you. Something like driving an
airplane instead of flying it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Don Miller said:
In my migration from ASP to ASP.NET 2.0, I have a fair number of
complicated HTML tables that defy anything .NET can do. Using classic ASP
I created these tables (by string concatenation) by moving forward, and
at times, backward through a recordset (using a static cursor rather than
a forward-only cursor).

I can't seem to find any methods in .NET to move to a previous row in a
Dataset (e.g. MovePrev, MoveFirst). Am I trying to use the wrong object
to navigate through rows of data returned from a database query? Is there
a better way?

Thanks for any direction.
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top