by Santhakumar Munuswamy
Posted on 22 十一月 2014
ASP.NET
在Asp.net中,网格视图控件用于对每一列进行标题行过滤,以基于从每一列数据的第一个字符开始的条件来搜索条件。在此示例网格视图过滤器应用程序中,使用了Linq查询概念,并且还绑定了数据表对象中的数据。它用于Linq查询以进行过滤,例如select语句,例如operator
GridviewFilterExample.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridviewFilterExample.aspx.cs" Inherits="GridviewFilterExample" %>
<!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>Gridview Filter Example</title>
<link rel="stylesheet" type="text/css" href="gridview.css" media="all" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 640px" border="0" cellpadding="0" cellspacing="6" class="GridviewTable">
<tr >
<td style="width: 120px">
Product ID
</td>
<td style="width: 120px">
Product Name
</td>
<td style="width: 120px">
Product Weight
</td>
<td style="width: 120px">
Product Price
</td>
<td style="width: 120px">
Product Expiry Date
</td>
</tr>
<tr >
<td style="width: 120px;">
<asp:TextBox ID="txtProductId" runat="server" Width="75px"></asp:TextBox>
<asp:Button ID="btnProductId" runat="server" Text="Go"
onclick="btnProductId_Click" />
</td>
<td style="width: 120px;">
<asp:TextBox ID="txtProductName" runat="server" Width="75px"></asp:TextBox>
<asp:Button ID="btnProductName" runat="server" Text="Go"
onclick="btnProductName_Click" />
</td>
<td style="width: 120px;">
<asp:TextBox ID="txtProductWeight" runat="server" Width="75px"></asp:TextBox>
<asp:Button ID="btnProductWeight" runat="server" Text="Go"
onclick="btnProductWeight_Click" />
</td>
<td style="width: 130px;">
<asp:TextBox ID="txtProductPrice" runat="server" Width="75px"></asp:TextBox>
<asp:Button ID="btnProductPrice" runat="server" Text="Go"
onclick="btnProductPrice_Click" />
</td>
<td style="width: 130px;">
<asp:TextBox ID="txtProductExpiryDate" runat="server" Width="75px"></asp:TextBox>
<asp:Button ID="btnProductExpiryDate" runat="server" Text="Go"
onclick="btnProductExpiryDate_Click" />
</td>
</tr>
<tr>
<td colspan="5">
<asp:GridView ID="gvProductDtls" runat="server" AutoGenerateColumns="False"
Width="640px" CssClass="Gridview" ShowHeader="False" >
<Columns>
<asp:BoundField DataField="ProducId" ItemStyle-Width="120px" >
<ItemStyle Width="120px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="ProductName" ItemStyle-Width="120px" >
<ItemStyle Width="120px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="ProductWeight" ItemStyle-Width="120px" >
<ItemStyle Width="120px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="ProductPrice" ItemStyle-Width="130px" >
<ItemStyle Width="130px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="ProductExpiryDate" ItemStyle-Width="130px" >
<ItemStyle Width="130px"></ItemStyle>
</asp:BoundField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
来自我的旧博客的来源: 阅读更多