如何使用MS SQL DABABASE TABLE中的列数据在asp.net C#中创建动态表 [英] how to create dynamic table in asp.net C# using columns data from MS SQL DABABASE TABLE
本文介绍了如何使用MS SQL DABABASE TABLE中的列数据在asp.net C#中创建动态表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
而不是采用gridview,Iam尝试从asp.net中的后端代码c#生成一个表;;
我们看到通过gridview,我们将将gridview连接到数据库,我们将获得数据库表中的所有值;;就像iam试图通过从后端代码C#生成表一样,我想通过查询来从数据库中显示表中的数据sql
Instead of taking gridview, Iam trying to generate a table from backend code c# in asp.net;;
As we see that by taking gridview, we will connect gridview to database and we will get all values present in the data base table;; same like that iam trying to do by generating table from backend code C# and I want to pass query to show data in table from data base sql
推荐答案
这很简单在MVC中你觉得C#很复杂。因为你必须为分类,分页和itemCommand编写单独的代码。
对于简单的表绑定,首先指定文字/标签
It was quite simple in MVC but you feel complex in C#. Because you have to write seperate code for sorting, paging and itemCommand.
For simple table binding, First assign literal/ label
<asp:literal id="ltlTable" runat="server" xmlns:asp="#unknown" />
string strVal= "<table>";
for(int i=0;i<datatable.columns.count;i++)>
{
strVal+="<tr>";
for(int j=0;j&<datatable.rows.count;j++)>
{
strVal+="<td>";
strVal+= dataTable.Rows[i][j].toString();
strVal+="</td>";
}
strVal+="</tr>";
}
strVal+="</table>";
ltlTable.Value = strVal.toString();
这篇关于如何使用MS SQL DABABASE TABLE中的列数据在asp.net C#中创建动态表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文