Amit Kumar

Amit Kumar

  • NA
  • 140
  • 41.1k

search with gridview

Jan 24 2014 4:03 AM
i have gridview, in i have implemented search option to search the record . but i want to implement one more functionality like

http://i.tinyuploads.com/sWc7KQ.jpg
like how many recoed have been found according to user search .
eg (10 records founds )
here is my code 
 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="GridviewDiv">
<p>
Enter UserName :
<asp:TextBox ID="txtSearch" runat="server" />&nbsp;&nbsp;
<asp:ImageButton ID="btnSearch" ImageUrl="~/SearchButton.png" runat="server"
Style="top: 5px; position: relative" OnClick="btnSearch_Click" />&nbsp;&nbsp;
<asp:ImageButton ID="btnClear" ImageUrl="~/Clearbutton.png" runat="server" Style="top: 5px; position: relative"
OnClick="btnClear_Click" /><br />
<br />
</p>
<asp:GridView ID="gvDetails" runat="server" Width="332px" AllowPaging="true" AllowSorting="true"
AutoGenerateColumns="false" CssClass="Gridview" PageSize="3" DataSourceID="dsDetails">
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Name")%>'>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("City")%>'>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sex">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Sex")%>'>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="dsDetails" runat="server" ConnectionString="<%$ConnectionStrings:connect %>" SelectCommand="select * from emp" FilterExpression="Name LIKE '%{0}%'">
<FilterParameters>
<asp:ControlParameter Name="Name" ControlID="txtSearch" PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
</div>
</ContentTemplate>
</asp:UpdatePanel>
 

Answers (4)