Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi

In Gridview I bind all data from database , Now I want Search Data using TextBox In gridview Please Help me out

Here the GridView Code


XML
<asp:GridView ID="GridView1" Width="100%" PageSize="10" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Employee_Designation_ID" DataSourceID="View_Designation" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowEditButton="True" />
                        <asp:BoundField DataField="Employee_Designation_ID" HeaderText="Designation Id" ReadOnly="True" SortExpression="Employee_Designation_ID" />
                        <asp:BoundField DataField="Employee_Designation_Name" HeaderText="Designation Name" SortExpression="Employee_Designation_Name" />
                        <asp:BoundField DataField="Per_year_Leave" HeaderText="Paid Leave / Year" SortExpression="Per_year_Leave" />
                        <asp:BoundField DataField="Charge_per_leave" HeaderText="Charge / Leave" SortExpression="Charge_per_leave" />
                        <asp:BoundField DataField="Designation_Detail" HeaderText="Detail" SortExpression="Designation_Detail" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                   <asp:SqlDataSource ID="View_Designation" runat="server" ConnectionString="<%$ ConnectionStrings:CMMS_Standard %>" DeleteCommand="DELETE FROM [Employee_Designation] WHERE [Employee_Designation_ID] = @Employee_Designation_ID" InsertCommand="INSERT INTO [Employee_Designation] ([Employee_Designation_ID], [Employee_Designation_Name], [Per_year_Leave], [Charge_per_leave], [Designation_Detail]) VALUES (@Employee_Designation_ID, @Employee_Designation_Name, @Per_year_Leave, @Charge_per_leave, @Designation_Detail)" ProviderName="<%$ ConnectionStrings:CMMS_Standard.ProviderName %>" SelectCommand="SELECT [Employee_Designation_ID], [Employee_Designation_Name], [Per_year_Leave], [Charge_per_leave], [Designation_Detail] FROM [Employee_Designation]" UpdateCommand="UPDATE [Employee_Designation] SET [Employee_Designation_Name] = @Employee_Designation_Name, [Per_year_Leave] = @Per_year_Leave, [Charge_per_leave] = @Charge_per_leave, [Designation_Detail] = @Designation_Detail WHERE [Employee_Designation_ID] = @Employee_Designation_ID">
                       <DeleteParameters>
                           <asp:Parameter Name="Employee_Designation_ID" Type="Byte" />
                       </DeleteParameters>
                       <InsertParameters>
                           <asp:Parameter Name="Employee_Designation_ID" Type="Byte" />
                           <asp:Parameter Name="Employee_Designation_Name" Type="String" />
                           <asp:Parameter Name="Per_year_Leave" Type="Byte" />
                           <asp:Parameter Name="Charge_per_leave" Type="Int16" />
                           <asp:Parameter Name="Designation_Detail" Type="String" />
                       </InsertParameters>
                       <UpdateParameters>
                           <asp:Parameter Name="Employee_Designation_Name" Type="String" />
                           <asp:Parameter Name="Per_year_Leave" Type="Byte" />
                           <asp:Parameter Name="Charge_per_leave" Type="Int16" />
                           <asp:Parameter Name="Designation_Detail" Type="String" />
                           <asp:Parameter Name="Employee_Designation_ID" Type="Byte" />
                       </UpdateParameters>
                </asp:SqlDataSource>

And Here the Two Textbox

XML
<div class="col-lg-3">
                       <div class="input-group">

                           <asp:TextBox ID="Designation_Id_TextBox" runat="server" placeholder="Enter Designation Id" CssClass="form-control"></asp:TextBox>
                       </div>
                       <!-- /input-group -->
                   </div>


                   <div class="col-lg-3">
                       <div class="input-group">
                           <asp:TextBox ID="Designation_Name_TextBox" runat="server" placeholder="Enter Designation Name" CssClass="form-control"></asp:TextBox>

                       </div>
                       <!-- /input-group -->
                   </div>

                   <div class="col-lg-2">
                       <asp:Button ID="Search_Button" CssClass="btn btn-default" runat="server" Text="Search" OnClick="Search_Button_Click" />
                   </div>



I want When i enter Id it show only data of that Id
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900