<asp:GridView ID="grdDonationRequests" runat="server" SelectMethod="grdDonationRequests_GetData" AutoGenerateColumns="False"
AllowPaging="True" PagerSettings-Mode="NumericFirstLast" PageSize="10" DataKeyNames="DonationRequestID" ItemType="Tayf.Models.DonationRequest"
AllowSorting="true" Width="100%" CssClass=" table-striped table-condensed table table-bordered table-hover" meta:resourcekey="grdDonationRequestsResource1">
我试图这样做
$(function () {
$("#<%=grdDonationRequests.ClientID%>").prepend(
$("thead>/thead>").append($(this).find("tr:first"))).dataTable({
});
});
但它给了我一个错误
Uncaught TypeError: Cannot read property 'className' of undefined
Update:-
当我尝试这个'$("#<%=grdDonationRequests.ClientID%>").dataTable({ "aaSorting": [] });'
时,它没有给我任何错误,也将gridview绘制为数据表但显示为空
答案 0 :(得分:1)
我现在正在做这件事。以下代码是将gridview实际转换为数据表所需的全部内容:
$(document).ready(function () {
var table = $('#your_gridview_id').DataTable();
希望这有帮助!
答案 1 :(得分:0)