效果图:
代码:
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”JqueryTableFilter.aspx.cs” Inherits=”JqueryTableFilter” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
<script src=”Script/jquery-1.3.2-vsdoc.js” type=”text/javascript”></script>
<script type=”text/javascript”>
$(function() {
$(“#Text1”).keyup(function() {
var filterText = $(this).val();
$(“#<%=GridView1.ClientID %> tr”).not(“:first”).hide().filter(“:contains(‘” + filterText + “‘)”).show();;
}).keyup();
});
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div style=”width:60%;”>
<input id=”Text1″ type=”text” />
<asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”
DataKeyNames=”OrderID” DataSourceID=”SqlDataSource1″
HorizontalAlign=”Left” PageSize=”50″ >
<Columns>
<asp:BoundField DataField=”OrderID” HeaderText=”OrderID” ReadOnly=”True”
SortExpression=”OrderID” InsertVisible=”False” />
<asp:BoundField DataField=”CustomerID” HeaderText=”CustomerID”
SortExpression=”CustomerID” />
<asp:BoundField DataField=”EmployeeID” HeaderText=”EmployeeID”
SortExpression=”EmployeeID” />
<asp:BoundField DataField=”OrderDate” HeaderText=”OrderDate”
SortExpression=”OrderDate” />
<asp:BoundField DataField=”RequiredDate” HeaderText=”RequiredDate”
SortExpression=”RequiredDate” />
<asp:BoundField DataField=”ShippedDate” HeaderText=”ShippedDate”
SortExpression=”ShippedDate” />
<asp:BoundField DataField=”ShipVia” HeaderText=”ShipVia”
SortExpression=”ShipVia” />
<asp:BoundField DataField=”Freight” HeaderText=”Freight”
SortExpression=”Freight” />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:NorthwindConnectionString %>”
SelectCommand=”SELECT top 50 * FROM [Orders]”></asp:SqlDataSource>










