如何在gridview中搜索记录 [英] how to search records in gridview

查看:57
本文介绍了如何在gridview中搜索记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在网格视图中搜索记录而不点击搜索按钮

如何在文本框中键入时搜索



我的代码是

搜索客户:
< asp:TextBox ID = < span class =code-keyword> txtSearch runat = server >
< asp:按钮 ID = btnSearch runat = 服务器 文本 = 搜索 / >
< hr / >
< asp:GridView ID = GridView1 HeaderStyle-BackColor = < span class =code-keyword>#3AC0F2
HeaderSt yle-ForeColor = 白色
< span class =code-attribute> runat = server AutoGenerateColumns = false DataSourceID = GridDataSource AllowPaging = true >
< columns >
< asp:BoundField DataField = 名称 HeaderText = 名称 < span class =code-attribute> ItemStyle-Width = 150 / >
< asp:BoundField DataField = InvestmentType HeaderText = 城市 ItemStyle-宽度 = 150 / >
< asp:BoundField DataField = 金额 HeaderText = 金额 ItemStyle-Width = 150 / >

< / columns >

< asp:SqlDataSource ID = GridDataSource runat = server ConnectionString = <% $ ConnectionStrings:ConStr %>
SelectCommand = SELECT Name,InvestmentType FROM PaymentTracker1
FilterExpression = 名称如此'%{0} %' >
< filterparameters >
< asp:ControlParameter 名称 = 名称 ControlID = txtSearch PropertyName = 文字 / >
< / filterparameters >



此代码正在搜索记录但当我点击搜索按钮...



以及如何在不使用sqldatasource的情况下绑定它我想用c#代码绑定



请帮帮我

解决方案

Conne ctionStrings:ConStr %>
< span class =code-attribute> SelectCommand = SELECT Name,InvestmentType FROM PaymentTracker1
FilterExpression = 名称类似'%{0}%' >
< filterparameters >
< asp:ControlParameter 名称 = 名称 ControlID = txtSearch PropertyName = 文字 / >
< / filterparameters >



此代码正在搜索记录,但是当我点击搜索按钮时...



以及如何绑定使用sqldatasource我想用c#代码绑定



pl轻松帮助我


请参阅自动填充文本框示例。如果它可能有用。



http://www.dotnetfunda.com/articles/show/225/creating-autocomplete-textbox-in-windows-froms-using -csharp。

how to search records in grid view without clicking search button
how to search while typing in textbox

my code is

Search Customer:
<asp:TextBox ID="txtSearch" runat="server">
<asp:Button ID="btnSearch" runat="server" Text="Search" />
<hr />
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
    runat="server" AutoGenerateColumns="false" DataSourceID="GridDataSource" AllowPaging="true">
    <columns>
        <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
        <asp:BoundField DataField="InvestmentType" HeaderText="City" ItemStyle-Width="150" />
        <asp:BoundField DataField="Amount" HeaderText="Amount" ItemStyle-Width="150" />

    </columns>

<asp:SqlDataSource ID="GridDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConStr %>"
    SelectCommand="SELECT Name, InvestmentType FROM PaymentTracker1"
    FilterExpression="Name LIKE '%{0}%'">
    <filterparameters>
        <asp:ControlParameter Name="Name" ControlID="txtSearch" PropertyName="Text" />
    </filterparameters>


this code is searching records but when i click search button...

and how to bind this without using sqldatasource i want to bind using c# code

please help me

解决方案

ConnectionStrings:ConStr %>" SelectCommand="SELECT Name, InvestmentType FROM PaymentTracker1" FilterExpression="Name LIKE '%{0}%'"> <filterparameters> <asp:ControlParameter Name="Name" ControlID="txtSearch" PropertyName="Text" /> </filterparameters>


this code is searching records but when i click search button...

and how to bind this without using sqldatasource i want to bind using c# code

please help me


Please see Autocomplete Text Box example. If it might helpful.

http://www.dotnetfunda.com/articles/show/225/creating-autocomplete-textbox-in-windows-froms-using-csharp.


这篇关于如何在gridview中搜索记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆