gberg927
gberg927

Reputation: 1686

LINQ - SQL Display data in html table

I would like to perform a select statement using a DataContext from the code behind page and then display the results in an HTML table.

Best ways to do this?

Upvotes: 0

Views: 916

Answers (2)

huMpty duMpty
huMpty duMpty

Reputation: 14460

If you really need to create html table you can use a literal in frontend and add the literal text from back end eg <asp:Literal ID="ltrUser" runat="server"></asp:Literal> In backend code

if (!IsPostBack)
        {
            var data = datasource;
            ltrUser.Text = "<table><tr><td>";
            ltrUser.Text += "<h1>"+ data.name + "</h1>";
            ltrUser.Text += "</td></tr></table>";
        }

Upvotes: 1

Dennis Traub
Dennis Traub

Reputation: 51624

The best way to do this as always depends. One of the fastest and easiest way would be to directly bind the data to a DataGrid.

Upvotes: 2

Related Questions