txbakers

msg:956351 | 6:21 am on Nov 24, 2002 (gmt 0) |
I do this quite often. Here is the code for doing it in 3 columns. You can adapt it. first, I declare some variables up in the top: var numstu = rsStudents.RecordCount; var sally = Math.round(numstu/3); var betty = sally * 2; Then, here is the first of the 3 columns: <td width="269" height="11" class="xxtxt"> <% if (rsStudents.EOF) { %> <% } else { %> <% for (var i=0; i < sally ; i++) { %> <%=(rsStudents.Fields.Item("first").value)%><br> <% rsStudents.MoveNext(); if (rsStudents.EOF){break} %> <% } %> <% } %> </td> finally, the other columns start this way: <% for (var i=betty ; i < numstu ; i++) { %> and <% while (!rsStudents.EOF) { %> And there you have three columns.
|
Woz

msg:956352 | 6:45 am on Nov 24, 2002 (gmt 0) |
I do it a little differently, and perhaps not so elegantly, but it also seems to work. dim some variables such as strLeft and strRight and do something like this for i = 0 to TotalRecords if RecordCount =< (TotalRecords/2) then StrLeft = "what ever you want" else strRight = "whatever you want" end if ors.movenext Then populate the two halves of a table with strLeft and strRight, remebering to get them on the correct side. ;) Onya Woz
|
newnewbie1

msg:956353 | 1:48 pm on Nov 24, 2002 (gmt 0) |
OH, I see what you are doing, but I don't think that's quite what I want. I want to paint the table horizontally... My result set is 18 doctors, I want to have a table that looks like this: Doctor1 Doctor2 Doctor3 Doctor4 Doctor5 Doctor6 Doctor7 Doctor8 Doctor9 Doctor10 Doctor11 Doctor12 Doctor13 Doctor14 Doctor15 Doctor16 Doctor17 Doctor18 How can I do populate the left side, then the right side of the table? Thanks!
|
duckhunter

msg:956354 | 2:27 pm on Nov 24, 2002 (gmt 0) |
Take a look at the Table object System.Web.UI.WebControls [edited by: duckhunter at 2:40 pm (utc) on Nov. 24, 2002]
|
duckhunter

msg:956355 | 2:40 pm on Nov 24, 2002 (gmt 0) |
Here ya go. | Code Behind Loading Dynamically |
| Imports System.Web.UI Imports System.Web.UI.WebControls Dim numrows As Integer = 3 Dim numcells As Integer = 2 Dim j As Integer For j = 0 To numrows - 1 Dim r As New TableRow() Dim i As Integer For i = 0 To numcells - 1 Dim c As New TableCell() c.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString())) r.Cells.Add(c) Next i Table1.Rows.Add(r) Next j <B>Table Example, constructed programmatically</B> <form runat="server" ID="Form1"> <asp:Table id="Table1" GridLines="Both" HorizontalAlign="Center" Font-Name="Verdana" Font-Size="8pt" CellPadding="5" CellSpacing="0" Runat="server" /> </form>
|
AussieStu

msg:956356 | 2:16 am on Dec 6, 2002 (gmt 0) |
Well I'm probably too late to help you out but here goes anyway. I'm gunna try to do it with your code so as to be sure that you'll be able to figure out how it goes: <td class="formRegPurple" valign="top"> <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center"> <% do until recData.EOF %> <tr> <td class="formRegPurple"> <input type="radio" name="DoctorID" value="<%=recData.Fields("DoctorID")%>" <% if recData.Fields("DoctorID") = session("DoctorID") then%> checked <%end if %>> <%=recData.Fields("DoctorName")%> </td> <td class="formRegPurple"> <% recData.movenext if not recData.EOF then %> <input type="radio" name="DoctorID" value="<%=recData.Fields("DoctorID")%>" <% if recData.Fields("DoctorID") = session("DoctorID") then%> checked <%end if %>> <%=recData.Fields("DoctorName")%> <% else %> <% end if %> </td></tr> <% recData.movenext Loop %> You just put in another <td> .. </td> just like your first one and put an in it if you run out of records. To me that's the simplest way to do it (and that's a good thing!). Cheers!
|
|