开发者

LINQ - SQL Display data in html table

开发者 https://www.devze.com 2023-04-07 07:14 出处:网络
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.

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开发者_运维知识库?


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.


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>";
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号