Forum Moderators: open
I've got a Query that is bring back a result set- it's a list of doctors. I would like to make this a 2 column table and list the doctors side by side.
There's 18 doctors, and I'd like to have 9 rows with 2 columns... I can't figure out how to do this...
If the record count is odd I would like to print that record in the left had column, if it's even, I'd like to print it in the right hand column...
Here part of my code:
<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><tr>
<% recData.movenext
Loop
%>
Can anybody think of how to do this?
I am STUCK!
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.
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
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!
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
HTML Code
<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>
<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!