Table Question

G

Guest

When I did classic ASP, I could build a table that has two columns above an
image that spanned the two columns, or two rows next to an image that spanned
the two rows. I would populate the table from a Recordset like this:

<CENTER>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=2 WIDTH=600>
<%
Do While Not RS.EOF
For x = 0 To UBound(arrImage) %>
<TR BGCOLOR="#C0C0C0"><TH ALIGN=RIGHT
WIDTH=200><%=RS("Description1")%></TH><TH COLSPAN=2><%=RS("ItemNumber")%></TH>
<TR ALIGN="center">
<TD COLSPAN="3"><IMG SRC="/images/<%=arrImage(x)%>"></TD>
</TR>
<% RS.MoveNext
Next 'x
Loop 'While Not RS.EOF

How do I do this same thing in ASP.NET using a Repeater or a DataGrid or
whatever control is appropriate? I have a DataSet built to retrieve the
data, I just need help displaying it.

Thx,
 
S

Steve C. Orr [MVP, MCSD]

How about this code?

DataGrid1.DataSource = MyDataSet
DataGrid1.DataBind()
 
D

Daniel Walzenbach

Hi,
why don't you do the same you did with asp? Only because there now is sth.
like asp.net it does not mean that one has to forget everything one knows!
Why don't you use sth like:

Dim myTable As New System.Web.UI.HtmlControls.HtmlTable

Dim myTR As System.Web.UI.HtmlControls.HtmlTableRow
Dim myTD As System.Web.UI.HtmlControls.HtmlTableCell

For Each row As System.Data.DataRow In myDataTable.Rows

myTR = New System.Web.UI.HtmlControls.HtmlTableRow

For Each obj As Object In row.ItemArray

myTD = New System.Web.UI.HtmlControls.HtmlTableCell()
' do what you want with the cell

myTR.Cells.Add(myTD)

Next

myTable.Rows.Add(myTR)

Next

Page.Controls.Add(myTable)

if you want to get fancy, otherwise stick to Steves suggestion!

Regards

Daniel Walzenbach
 

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

Top