如何在网格视图的顶部添加搜索 [英] How to add search in top of the grid view

查看:85
本文介绍了如何在网格视图的顶部添加搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要网格视图标题搜索



我尝试过:



< asp:GridView ID =gridViewDataKeyNames =FuelTypeIdrunat =server

AutoGenerateColumns =falseShowFooter =trueHeaderStyle-Font-Bold =true

OnRowCancelingEdit =gridView_RowCancelingEdit

OnRowDeleting =gridView_RowDeleting

OnRowEditing =gridView_RowEditing

OnRowUpdating = gridView_RowUpdating

OnRowCommand =gridView_RowCommand

OnRowDataBound =gridView_RowDataBoundCssClass =gridviewAllowPaging =trueOnPageIndexChanging =OnPaging>



< columns> < asp:TemplateField HeaderText =燃料类型>

< itemtemplate>

< asp:标签ID =lblnamerunat =serverText = '<%#Eval(FuelType)%>'/>



< edititemtemplate>





< asp:TextBox ID = txtfueltypeMaxLength =50runat =serverclass =form-controlText ='<%#Eval(FuelType)%>'/>





< asp:RequiredFieldValidator ID =RequiredFieldValidator1runat =serverControlToValidate =txtfueltypeErrorMessage =请输入MakeNameText =*ValidationGroup =editvalidation CssClass =cssValidation>







< footertemplate> ;





< asp:TextBox ID =txtfuelnewMaxLength =50占位符=燃料类型runat =serverclass =form-control/>





< asp:RequiredFieldValidator ID =RequiredFieldValidator2 runat =serverControlToValidate =txtfuelnewErrorMessage =请输入MakeNameText =*ValidationGroup =validaitonCssClass =cssValidation>









< asp:TemplateField>

< edititemtemplate>

< asp:Button ID = ButtonUpdateValidationGroup =editvalidationrunat =serverCommandName =UpdateText =Updateclass =btn btn-default btn-xs/>

< asp:Button ID =ButtonCancelrunat =serverCommandName =CancelText =Cancelclass =btn btn-default btn-xs/>



< ; itemtemplate>

< asp:Button ID =ButtonEditrunat =serverCommandName =EditText =Editclass =btn btn-default btn-xs/>

< asp:Button ID =ButtonDeleterunat =serverCommandName =DeleteText =Deleteclass =btn btn-default btn-xs/>



< foo tertemplate>

< asp:Button ID =ButtonAddOnClientClick =addclick(); ValidationGroup =validaitonrunat =serverCommandName =AddNewText =Addclass =btn btn-default btn-xs/>

< button type =reset >重置< / button>




解决方案

在'SqlDataSource的帮助下'和'FilterExpression'你可以完成你的任务。

首先在gridview上面添加一个文本框和一个搜索按钮,将'DataSourceID'添加到gridview(应该与'SqlDataSource'相同)

见下面链接

在ASP.Net的SqlDataSource中使用FilterExpression过滤带有TextBox的GridView [ ^

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>


解决方案

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[^]


这篇关于如何在网格视图的顶部添加搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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