473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

sorting table into 2 columns

Hi
I have a simple ASP question.
I am experimenting a little with asp, and I am trying to view a page from a
database.
The thing is, i am seeing all my data, in one long column.
How can I split it up into two columns.
I have created a no jargon page, just for the example,
http://www.tripakltd.com/check.asp
the source code is
http://www.tripakltd.com/check.txt
I hope someone can help me with this

Thanks so much

Raphael
Jul 19 '05 #1
4 1933
One way (of many) is to create two variables hold alternate values from the
recordset

Dim column1, column2
Dim counter

column1 = "<td width=50%>"
column2 = "<td width=50%>"

' Initialize the counter
counter = 0

' This is your while loop
While. ...

' Alternate adding value to the string
If counter Mod 2 = 0 Then
' Add the checkbox and recordset value to the first string
column1 = column1 & "<input type=checkbox ....." &
rsFeedback("....")
Else
' Add the checkbox and recordset value to the second string
column2 = column2 & "<input type=checkbox ....." &
rsFeedback("....")
End If

' Complete the TD tag
column1 = column1 & "</td>"
column2 = column2 & "</td>"

' Now, print the values of these variables
Response.Write("<table><tr>")
Response.Write(column1)
Response.Write(column2)
Response.Write("</tr></table>")

rsFeedback.MoveNext
Wend

This is not the most efficient way, since you are concatenating strings.
Another way, especially if you have a count of records (say using
disconnected recordset), is to use RecordCount property of the recordset to
count upto the half for one TD, and start another TD, and Response.Write all
the way:

' Make sure you can somehow read recordcount (disconnected RS, etc)
halfCount = Int(rsFeedBack.RecordCount/2)
Counter = 0

' Start the first TD
Response.Write("<table><tr>")
Response.Write("<td>")

' This is your while loop
While. ...

' Check to see if half the count has passed
If counter > halfCount Then
' End the previous TD and Start a new TD
Response.Write("</td><td>")
End If

' Print the values
Response.Write("<input type=checkbox....>")
Response.Write(rsFeedback("..."))

rsFeedback.MoveNext
Wend

Hope that helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Raphael Gluck" <so***@nospam.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
Hi
I have a simple ASP question.
I am experimenting a little with asp, and I am trying to view a page from a database.
The thing is, i am seeing all my data, in one long column.
How can I split it up into two columns.
I have created a no jargon page, just for the example,
http://www.tripakltd.com/check.asp
the source code is
http://www.tripakltd.com/check.txt
I hope someone can help me with this

Thanks so much

Raphael

Jul 19 '05 #2
Wow, thanks for all that help!
Thanks
"Manohar Kamath [MVP]" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
One way (of many) is to create two variables hold alternate values from the recordset

Dim column1, column2
Dim counter

column1 = "<td width=50%>"
column2 = "<td width=50%>"

' Initialize the counter
counter = 0

' This is your while loop
While. ...

' Alternate adding value to the string
If counter Mod 2 = 0 Then
' Add the checkbox and recordset value to the first string
column1 = column1 & "<input type=checkbox ....." &
rsFeedback("....")
Else
' Add the checkbox and recordset value to the second string
column2 = column2 & "<input type=checkbox ....." &
rsFeedback("....")
End If

' Complete the TD tag
column1 = column1 & "</td>"
column2 = column2 & "</td>"

' Now, print the values of these variables
Response.Write("<table><tr>")
Response.Write(column1)
Response.Write(column2)
Response.Write("</tr></table>")

rsFeedback.MoveNext
Wend

This is not the most efficient way, since you are concatenating strings.
Another way, especially if you have a count of records (say using
disconnected recordset), is to use RecordCount property of the recordset to count upto the half for one TD, and start another TD, and Response.Write all the way:

' Make sure you can somehow read recordcount (disconnected RS, etc)
halfCount = Int(rsFeedBack.RecordCount/2)
Counter = 0

' Start the first TD
Response.Write("<table><tr>")
Response.Write("<td>")

' This is your while loop
While. ...

' Check to see if half the count has passed
If counter > halfCount Then
' End the previous TD and Start a new TD
Response.Write("</td><td>")
End If

' Print the values
Response.Write("<input type=checkbox....>")
Response.Write(rsFeedback("..."))

rsFeedback.MoveNext
Wend

Hope that helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Raphael Gluck" <so***@nospam.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
Hi
I have a simple ASP question.
I am experimenting a little with asp, and I am trying to view a page
from a
database.
The thing is, i am seeing all my data, in one long column.
How can I split it up into two columns.
I have created a no jargon page, just for the example,
http://www.tripakltd.com/check.asp
the source code is
http://www.tripakltd.com/check.txt
I hope someone can help me with this

Thanks so much

Raphael


Jul 19 '05 #3
ljb
"Raphael Gluck" <so***@nospam.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
How can I split it up into two columns.
I have created a no jargon page, just for the example,
http://www.tripakltd.com/check.asp


One way or another you need to determine how many rows your recordset
contains. Then open an html table placing half the records in cell one with
each record followed by <br>. Close cell one, open cell two and place the
rest there. I prefer this because alphabetically sorted records read from
top down rather than across two columns. I usually place all my records into
an array with rs.getrows. It makes it easy to jump directly to an element or
use ubound() to get an accurate count of records since ADO often doesn't
provide one.

LJB
Jul 19 '05 #4
ljb wrote on 01 apr 2004 in microsoft.public.inetserver.asp.general:
One way or another you need to determine how many rows your recordset
contains. Then open an html table placing half the records in cell one
with each record followed by <br>. Close cell one, open cell two and
place the rest there. I prefer this because alphabetically sorted
records read from top down rather than across two columns. I usually
place all my records into an array with rs.getrows. It makes it easy
to jump directly to an element or use ubound() to get an accurate
count of records since ADO often doesn't provide one.


Making a real "dual vertical sorted" table is relatively easy:

response.write "<table>" & VbCrLf
for rec=0 to numberOfRecords-1 step 2
response.write "<tr>"
insertCell(rec)
insertCell(rec+numberOfRecords\2) ' integer division
response.write "</tr>" & VbCrLf
next
response.write "</table>" & VbCrLf
function insertCell(rec)
response.write "<td>"
if rec<=numberOfRecords then response.write arrayRecord(rec)
response.write "</td>"
end sub

not tested

a three column vertical sorted table is not much more work

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
17
by: Matt Kruse | last post by:
I'm looking for the best JS/CSS solution to add functionality to tables. The only browser which needs to be supported is IE5.5+, but no activeX can be used. to be able to do: - Fixed header row...
4
by: Gareth Gale | last post by:
I'm trying to implement a way of allowing a user to sort a HTML table via Javascript on the client. I've seen lots of samples where single column sorting (asc or desc) is shown, but I'd like nested...
11
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I...
3
by: WB | last post by:
Hi, I have a DataTable, which I'd like to sort before using it for other operation. However, I notice that even after I call the .DefaultView.Sort = "username", the view is still not sorted. For...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
3
by: nagmvs | last post by:
Hi to all I have one table with 6 columns and 20 rows.I want to sort each and every column when i click the column name in the table. for sorting i create one more page.when i click the column...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.