使用JqueryDatatable将动态列标题和数据从数据集绑定到转发器

时间:2016-07-14 11:06:15

标签: c# jquery asp.net data-binding datatable

<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>
    <tr class="">
        <asp:Repeater ID="Header1" runat="server">
            <ItemTemplate>
                <th align="left"><%# Container.DataItem %>
                </th>
            </ItemTemplate>
        </asp:Repeater>
    </tr>
</HeaderTemplate>
<ItemTemplate>
    <tr class="">
        <asp:Repeater ID="Item1" runat="server">
            <ItemTemplate>
                <td><%# Container.DataItem %>
                </td>
            </ItemTemplate>
        </asp:Repeater>
    </tr>
</ItemTemplate>

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 
{
    if (e.Item.ItemType == ListItemType.Header)
    {
        Repeater headerRepeater = e.Item.FindControl("Header1") as Repeater;
        headerRepeater.DataSource = dt.Columns;
        headerRepeater.DataBind();
    }

   if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Repeater columnRepeater = e.Item.FindControl("Item1") as Repeater;
        var row = e.Item.DataItem as System.Data.DataRowView;
        columnRepeater.DataSource = row.Row.ItemArray;
        columnRepeater.DataBind();
    }
}

我的要求是动态添加列,数据属于该列。我用谷歌搜索,我得到一个链接Bind Dynamic data and column to repeater 这工作正常。但我想将Jquery.datatable.js应用于排序和分页功能以及默认使用jquery的数据表

的其他功能

我该怎么办?

0 个答案:

没有答案