使用 bootstrap 和 datatables.net 插件
protected void rptReport_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Repeater headerRepeater = e.Item.FindControl("Header1") as Repeater;
headerRepeater.DataSource = dtOrder.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();
}
}
<link href="/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<link href="/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
<div class="row">
<div class="col-md-12">
<asp:Panel runat="server" ID="pnlReport">
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption font-dark">
<i class="icon-settings font-dark"></i>
<span class="caption-subject bold">Sonuçlar </span>
</div>
<div class="tools"></div>
</div>
<div class="portlet-body">
<asp:Repeater ID="rptReport" runat="server" OnItemDataBound="rptReport_ItemDataBound">
<HeaderTemplate>
<table class="table table-striped table-bordered table-hover" id="tblReport">
<thead>
<tr>
<asp:Repeater ID="Header1" runat="server">
<ItemTemplate>
<th><%# Container.DataItem %></th>
</ItemTemplate>
</asp:Repeater>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<asp:Repeater ID="Item1" runat="server">
<ItemTemplate>
<td><%# Container.DataItem %></td>
</ItemTemplate>
</asp:Repeater>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</asp:Panel>
</div>
</div>
<script type="text/javascript" src='<%=ResolveUrl("~/jquery.min.js") %>'></script>
<script type="text/javascript" src='<%=ResolveUrl("~/bootstrap.min.js") %>'></script>
<script src='<%=ResolveUrl("~/scripts/datatable.js") %>' type="text/javascript"></script>
<script src='<%=ResolveUrl("~/datatables/datatables.min.js") %>' type="text/javascript"></script>
<script src='<%=ResolveUrl("~/bootstrap/datatables.bootstrap.js") %>' type="text/javascript"></script>
<script>
$(document).ready(function () {
$('#tblReport').DataTable({
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Turkish.json",
"decimal": ",",
"thousands": ".",
buttons: {
copyTitle: 'Panoya kopyalandı',
copyKeys: 'Appuyez sur <i>ctrl</i> ou <i>\u2318</i> + <i>C</i> pour copier les données du tableau à votre presse-papiers. <br><br>Pour annuler, cliquez sur ce message ou appuyez sur Echap.',
copySuccess: {
_: '%d satır kopyalandı',
1: '1 satır kopyalandı'
}
}
},
buttons: [
{ extend: 'print', className: 'btn dark btn-outline', text: 'Yazdır' },
{ extend: 'copy', className: 'btn red btn-outline', text: 'Kopyala' },
{ extend: 'pdf', className: 'btn green btn-outline' },
{ extend: 'excel', className: 'btn yellow btn-outline ' },
{ extend: 'csv', className: 'btn purple btn-outline ' },
{ extend: 'colvis', className: 'btn dark btn-outline', text: 'Kolonlar' }
],
"order": [
[0, 'asc']
],
"lengthMenu": [
[5, 10, 50, -1],
[5, 10, 50, "Hepsi"]
],
"pageLength": 10,
"dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
});
});
</script>