Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i need grid-view header search

What I have tried:

<asp:GridView ID="gridView" DataKeyNames="FuelTypeId" runat="server"
AutoGenerateColumns="false" ShowFooter="true" HeaderStyle-Font-Bold="true"
OnRowCancelingEdit="gridView_RowCancelingEdit"
OnRowDeleting="gridView_RowDeleting"
OnRowEditing="gridView_RowEditing"
OnRowUpdating="gridView_RowUpdating"
OnRowCommand="gridView_RowCommand"
OnRowDataBound="gridView_RowDataBound" CssClass="gridview" AllowPaging="true" OnPageIndexChanging="OnPaging">

<columns> <asp:TemplateField HeaderText="Fuel Type">
<itemtemplate>
<asp:Label ID="lblname" runat="server" Text='<%#Eval("FuelType") %>' />

<edititemtemplate>


<asp:TextBox ID="txtfueltype" MaxLength="50" runat="server" class="form-control" Text='<%#Eval("FuelType") %>' />


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtfueltype" ErrorMessage="Please enter the MakeName" Text="*" ValidationGroup="editvalidation" CssClass="cssValidation">



<footertemplate>


<asp:TextBox ID="txtfuelnew" MaxLength="50" placeholder="Fuel Type" runat="server" class="form-control"/>


<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtfuelnew" ErrorMessage="Please enter the MakeName" Text="*" ValidationGroup="validaiton" CssClass="cssValidation">




<asp:TemplateField>
<edititemtemplate>
<asp:Button ID="ButtonUpdate" ValidationGroup="editvalidation" runat="server" CommandName="Update" Text="Update" class="btn btn-default btn-xs" />
<asp:Button ID="ButtonCancel" runat="server" CommandName="Cancel" Text="Cancel" class="btn btn-default btn-xs" />

<itemtemplate>
<asp:Button ID="ButtonEdit" runat="server" CommandName="Edit" Text="Edit" class="btn btn-default btn-xs" />
<asp:Button ID="ButtonDelete" runat="server" CommandName="Delete" Text="Delete" class="btn btn-default btn-xs" />

<footertemplate>
<asp:Button ID="ButtonAdd" OnClientClick="addclick();" ValidationGroup="validaiton" runat="server" CommandName="AddNew" Text="Add" class="btn btn-default btn-xs" />
<button type="reset" >Reset</button>


Posted
Updated 21-Mar-16 20:00pm
v4
Comments
dan!sh 22-Mar-16 1:46am    
Not a good question. Reported.

You have not shown if you have put in any kind of effort.

1 solution

with the help of 'SqlDataSource' and 'FilterExpression' you can be able to accomplish your task.
First add a textbox and a search button above gridview, add 'DataSourceID' to gridview (which should be same as 'SqlDataSource')
see below link
Filter GridView with TextBox using FilterExpression in SqlDataSource in ASP.Net[^]
 
Share this answer
 
Comments
Gokul sn 22-Mar-16 2:15am    
Now i need header search for my type code
koolprasad2003 22-Mar-16 2:39am    
Do not add a search button and a textbox in header, simple put it above the grid as shown in my given link, Have you checked it ?

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