【Asp.Net从零开始】:使用LinqToData与QueryExtender对数据进行筛选性输出

<body>
    <form id="form1" runat="server">
    <div>
    
        演练链接:<a href="http://msdn.microsoft.com/zh-cn/library/dd537669">http://msdn.microsoft.com/zh-cn/library/dd537669</a></div>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="NORTHWNDDataContext" EntityTypeName="" TableName="Categories">
    </asp:LinqDataSource>
    <asp:QueryExtender ID="QueryExtender1" runat="server" 
        TargetControlID="LinqDataSource1">
        <asp:SearchExpression  SearchType="StartsWith" DataFields="CategoryName">
  <asp:ControlParameter ControlID="tb_search" />
</asp:SearchExpression>
    </asp:QueryExtender>
    <br />
    SearchExpression指定匹配搜索:
    <asp:TextBox id="tb_search" runat="server" />
    <asp:Button Text="Search!" Id="button1" runat="server" />
    

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="CategoryID" 
        DataSourceID="LinqDataSource1">
        <Columns>
            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
                InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" />
            <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
                SortExpression="CategoryName" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
        </Columns>
    </asp:GridView>
    
    

    </form>
</body>

  

原文地址:https://www.cnblogs.com/VortexPiggy/p/2635948.html