Data Grid layout

  • Thread starter Craig Hudson-Bennett
  • Start date
C

Craig Hudson-Bennett

I am trying to copy this asp layout in asp.net...

www.podge.net/AdvertList.asp?CategoryID=1

in asp, i looped through the recordset and created a new table for each
new DatePosted date. in asp.net i am hoping to use a data grid, but i'm
not sure how to create a separate block for each DatePosted date. will i
need a separate data grid for each DatePosted, or can I format one data
grid to look like me old asp layout?

thanks, Craig
 
E

E. Wise

One way to solve this would be to create a dataset with fields PostDate,
Description, Location sorted by date.

After you fill the dataset walk through it with a for each and add a header
row every time the date changes. Here is some pseudocode to help you get
started. (I'm in a hurry so the syntax will be a little sloppy, hopefully
you'll get the idea and adjusting the code shouldn't be too bad)

Dim x, y As Integer

Dim myRow As DataRow

Dim intDateCount As Integer = -1 'Would be -2 if you wanted a header and a
footer after each section

Dim strLastDate As Date

Dim myNewRow As DataRow



'Find out how many unique dates there are in the set


For Each myRow In DsRooms.Tables(0).Rows


If strLastDate <> myRow.Item("PostDate") Then

intDateCount += 1

strLastDate = myRow.Item("PostDate")

End If

Next



'Set the upper bound of our loop to the number of rows plus the number of
headings we will add

y = DsRooms.Tables(0).Rows.Count + intDateCount



If DsRooms.Tables(0).Rows.Count > 0 Then

For x = 0 To y

myRow = DsRooms.Tables(0).Rows(x)

If strLastDate <> myRow.Item("PostDate") Then

'new date, insert a header

myNewRow = DsRooms.Tables(0).NewRow

myNewRow.Item("PostDate") = strLastDate

myNewRow.Item("Description") = strLastDate

myNewRow.Item("Location") = ""

DsRooms.Tables(0).Rows.InsertAt(myNewRow, x)

'set next date

strLastDate = myRow.Item("PostDate")

End If

Next


End If
 

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,796
Messages
2,569,645
Members
45,362
Latest member
OrderTrimKetoBoost

Latest Threads

Top