LiamGu LiamGu - 23 days ago 4
ASP.NET (C#) Question

Can't work out why I can't format this text

Now, I could be being a bit thick and be doing this the wrong way, but in short, I have a dataset where I run a query to retrieve what a customer has ordered. Specifically, I've picked one with multiple items in for testing purposes.

I'll spare you all the code but the specific bit I'm having an issue with is:

<script runat="server">
Do While reader.HasRows
Do While reader.Read

<td valign="top" width="100"><script runat="server">Response.Write(reader("SKUN"))</script><br /></td>
<td valign="top" width="200"><script runat="server">Response.Write(reader("DESCR"))</script></td>
<td valign="top" width="50"><script runat="server">Response.Write(reader("QORD"))</script></td>
<td valign="top" width="50"><script runat="server">Response.Write(reader("PRIC"))</script></td>
<script runat="server">

Ignore the inline code side of things, I'm working on another developers project and keeping in time with the way they work so it's easier for them to go back to.

However, this prints out exactly what I'm after, but it doesn't format it into rows in the table itself, it just prints one long line of text at the top of the page.

Am I missing something here or just purely doing it the wrong way? because I can't work out why it doesn't loop through the results to print out.


Try this:

 Do While reader.Read
        Dim tNewRow As New HtmlTableRow
        Dim cellSKU, cellDESCR, cellQORD, cellPRIC As New HtmlTableCell                
        orderNoLbl.Text = reader("NUMB")                
        cellSKU.InnerText = reader("SKUN")
        cellDESCR.InnerText = reader("DESCR")
        cellQORD.InnerText = reader("QORD")
        cellPRIC.InnerText = reader("PRIC")