我正在尝试使用jquerydatatable plugin
gridview.Data 在 gridview 中绑定但由于某种原因插件无法正常工作
我找不到确切的原因,但我在控制台中遇到如下错误。问题是我使用的脚本还是编码部分的问题?
TypeError: $(...).dataTable is not a function
Source File: http://localhost:3852/YouthPossibilities/jqDatatable.aspx
这是我使用的脚本
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js" ></script>
<script type="text/javascript" src="js/jquery.js" ></script>
<link href="css/demo_table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#gdView').dataTable();
})
</script>
这是aspx代码
<asp:GridView ID="gdView" runat="server" AutoGenerateColumns="False" OnPreRender="gdView_PreRender">
<Columns>
<asp:TemplateField HeaderText="FirstName">
<ItemTemplate >
<asp:Label ID="lblFstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName">
<ItemTemplate>
<asp:Label ID="lblLstName" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Organization">
<ItemTemplate>
<asp:Label ID="lblOrg" runat="server" Text='<%# Bind("Organization") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
这是我用于绑定gridview的c#代码
List<gdViewBAL> lstgdviewBAL = new List<gdViewBAL>();
gdViewDAL clsgdViewDAL = new gdViewDAL();
DataTable dt = clsgdViewDAL.GetData();
if (dt.Rows.Count > 0)
{
foreach (DataRow dRow in dt.Rows)
{
gdViewBAL clsgdviewBAL = new gdViewBAL();
clsgdviewBAL.Cellphone = dRow["CellPhone"].ToString();
clsgdviewBAL.Email = dRow["Email"].ToString();
clsgdviewBAL.Firstname = dRow["FirstName"].ToString();
clsgdviewBAL.Lastname = dRow["LastName"].ToString();
clsgdviewBAL.Organization = dRow["Organization"].ToString();
clsgdviewBAL.State1 = dRow["State1"].ToString();
clsgdviewBAL.Zip1 = dRow["Zip1"].ToString();
lstgdviewBAL.Add(clsgdviewBAL);
}
gdView.DataSource = lstgdviewBAL;
gdView.DataBind();
gdView.UseAccessibleHeader = true;
gdView.HeaderRow.TableSection = TableRowSection.TableHeader;
gdView.FooterRow.TableSection = TableRowSection.TableFooter;