Click to See Complete Forum and Search --> : Display results in 2 columns


collie
06-26-2008, 05:54 AM
Hi,



I have code that displays results in a table in one column. However, I need to display the results in 2 columns. The number of results return varies.

How can I modify the code to display results in 2 columns?

<table >
<%Do While Not rs.eof%>
<tr>
<td align=center class="defaulttext" width=1><input type=checkbox name="groupID" value="<%=IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value)%>" <% If InStr(grStr, "|" & IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value) & "|") > 0 Then%> checked<% End If%> <% If Not inmod(session("modAccess"), 4) Then%> disabled <% End If%>></td>
<td class="defaulttext"><%=IIF(IsDBNull(rs.Fields.Item("AGr_name").Value), Nothing, rs.Fields.Item("AGr_name").Value)%></td>
</tr>
<% rs.movenext()%>
<%Loop %>
</table>
Thanks

sstalder
06-26-2008, 01:45 PM
It's already setup for two columns.

collie
06-28-2008, 02:22 PM
Yes, it's set up for 2 columns -one for checkbox and the other one for the value.

I need to display results as follows:
checkbox value checkbox value

foetoid
06-30-2008, 12:56 PM
Can't you just insert another column in your data </td><td>

collie
07-01-2008, 01:37 AM
I can always add another column but how will I tell the results to split into 2 columns?

gabriele
07-01-2008, 06:32 PM
you will need to move in the recordset between the two columns ..


<table>
<%Do While Not rs.eof%>
<tr>
<td align=center class="defaulttext" width=1><input type=checkbox name="groupID" value="<%=IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value)%>" <% If InStr(grStr, "|" & IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value) & "|") > 0 Then%> checked<% End If%> <% If Not inmod(session("modAccess"), 4) Then%> disabled <% End If%>></td>
<td class="defaulttext"><%=IIF(IsDBNull(rs.Fields.Item("AGr_name").Value), Nothing, rs.Fields.Item("AGr_name").Value)%></td>
<!-- here we duplicate the column code to create the second column
but we will need to add some code to control some cases

first we move the recordset to the next record, and obtain the data for the next column
-->
<%rs.movenext%>
<!-- but now we have a problem ..
what if our recordset ends while we are at the first column ? we have nothing to put in the second column

but we can 'catch' this case because we have reached the eof of our recordset so
we add a conditional statement
-->
<%if not rs.eof then%>
<td align=center class="defaulttext" width=1><input type=checkbox name="groupID" value="<%=IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value)%>" <% If InStr(grStr, "|" & IIF(IsDBNull(rs.Fields.Item("AGr_id").Value), Nothing, rs.Fields.Item("AGr_id").Value) & "|") > 0 Then%> checked<% End If%> <% If Not inmod(session("modAccess"), 4) Then%> disabled <% End If%>></td>
<td class="defaulttext"><%=IIF(IsDBNull(rs.Fields.Item("AGr_name").Value), Nothing, rs.Fields.Item("AGr_name").Value)%></td>
<!-- and here we handle this case
What we do is to display two empty cells so that the browser will not consider the table erroneous ..
-->
<%else%>
<td>&nbsp;</td>
<td>&nbsp;</td>
<%end if%>
</tr>
<% rs.movenext()%>
<%Loop %>
</table>


hope this helps