Response.Write Horizontal Table from SQL Query using Dataview

791 views Asked by At

Still need help, no answer that has worked yet. Please jump in if you have any ideas.

I have been trying to get my Response.Write to go Horizontal, however I cannot seem to figure it out.

This is what I currently have (it all sits within a table) and loads from an sql database query using Dataview to get the vehicles I want to display:

Response.Write("<tr><td width='200px' colspan='3'><a href='car.aspx?invno=" & invno & "'><image runat='server' src='" + imageurl + "'></image></a></td></tr>")
Response.Write("<tr><td width='5px'>" + year + "</td><td width='10px'>" + make + "</td><td width='100px'>" + model + "</td></tr>")
Response.Write("<tr><td width='200px' colspan='3'>" + mileage + "</td></tr>")

However it is Currently giving me this Picture 1

But what I really want is this Picture 2

Any help would be greatly appreciated

Update

Ok so I am editing this whole post, as it was overly complicated with what I want. So I am breaking it down to its simplest:

</head>
<body>
    <form id="form1" runat="server">
    <asp:SqlDataSource runat="server" id="sqldata" ConnectionString="<%$ ConnectionStrings:cars %>" SelectCommand="SELECT TOP 3  ORDER BY NEWID() )">
        </asp:SqlDataSource>
        <asp:Panel ID="Panel1" runat="server">
            <div style="font-size: 10px; font-family: 'arial';">
                <center>
                <table id="list" border="0" cellpadding="2" cellspacing="0" width="200px">

            <%
                        Dim dv As Data.DataView = CType(sqldata.Select(DataSourceSelectArguments.Empty), Data.DataView)
                        For Each dr As Data.DataRow In dv.Table.Rows

                        Dim make As String = dr("make")

                            Response.Write("<tr><td>" + make + "</td></tr>")

                    Next
                        %> 
                    </table>

                </center>
            </div>
        </asp:Panel>
    </form>
</body>
</html>

So with the code above.. I get a vertical list

Ford
Chevy
Toyota

But what I want is a Horizontal list

Ford    Chevy    Toyota
1

There are 1 answers

3
Tushar Gupta On

Create a single row with 3 different columns to achieve your desired result

Response.Write("<tr><td width='200px' colspan='3'><a href='car.aspx?invno=" & invno & "'><image runat='server' src='" + imageurl + "'></image></a></td>")
Response.Write("<td width='5px'>" + year + "</td><td width='10px'>" + make + "</td><td width='100px'>" + model + "</td>")
Response.Write("<td width='200px' colspan='3'>" + mileage + "</td></tr>")