如何创建多个动态表 [英] How to create multiple dynamic tables

查看:70
本文介绍了如何创建多个动态表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建多个动态表。我在网上看过使用中继器和我看过的例子,但这些例子总是涵盖一个表。我需要创建MULTIPLE。例如:



I need to create multiple dynamic tables. I've looked online about using repeaters and I've seen examples, but these examples cover always ONE table. I need to create MULTIPLE ones. For instance:

<table>
    <tr>
        <td colspan="4" style="width: 200px; font-weight: bold, font-size: xxx; etc etc">
              HTML blah blah blah
        </td>
    </tr>
    <tr>
        <td>HTML</td>
       <td>LABEL CONTROL - basicallly a label control rendering data</td>
       <td>HTML</td>
       <td>LABEL CONTROL - bascially a label control rendering data</td>
     </tr>
     <tr>
         <td colspan="2">
         </td>
         <td colspan="2">
         </td>
     </tr>
       .
       .
       .
</table>





然后,我需要创建第二个表,可能是第三个,第四个,或第十个,等等。我走了这个?数据将来自Sharepoint List项目。我还需要为表格和TD添加样式。表中的任何按钮或数据都不会被用户更改...基本上,表格只会显示数据。



提前致谢。



我尝试了什么:



我读过有关使用中继器的信息,但是中继器我已经阅读过关于创建动态行和tablecells的内容,而不是表本身。



Then, I would need to create a second table, maybe a third, or fourth, or tenth, etc. How do I go about this? The data would be coming from a Sharepoint List item. I will also need to add style to the table and TDs. No buttons or data within the table will be changed by the user... basically, the table will only display data.

Thanks in advance.

What I have tried:

I've read about repeaters being used, but repeaters I've read about only cover creating dynamic rows and tablecells, not tables themselves.

推荐答案

您可以创建一个表并使用DataTable.Copy()或DataTable.Clone ()方法创建多个表,见下面的代码段



You can create one table and use DataTable.Copy() or DataTable.Clone() method to create multiple tables, see below snippet

DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Name");
dt.Columns.Add("Email");
dt.TableName = "MasterTable";

//insert into DataTable
dt.Rows.Add("1", "test1", "test1@gmail.com");
dt.Rows.Add("2", "test2", "test2@gmail.com");
dt.Rows.Add("3", "test3", "test3@gmail.com");

//Creating another DataTable to copy
DataTable dt_copy = new DataTable();
dt.TableName = "CopyTable";
dt_copy = dt.Copy();


这篇关于如何创建多个动态表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆