搜索和黑光行在 asp.net
本文关键字:asp net 搜索 | 更新日期: 2023-09-27 18:35:10
在asp中搜索并在网格视图行asp中突出显示结果
我该怎么做???????????
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False" Width="600px"
AllowPaging="True" PageSize="8"
CssClass="Grid"
AlternatingRowStyle-CssClass="alt"
PagerStyle-CssClass="pgr" DataSourceID="SqlDataSource1" >
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />
<asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
<asp:BoundField DataField="Time" HeaderText="Time" SortExpression="Time" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
</Columns>
<PagerStyle CssClass="pgr"></PagerStyle>
</asp:GridView
如果 grid 不过滤行,您可以在RowDataBound
事件中添加 css 类。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row;
if(/*row matches search pattern*/)
{
row.CssClass = "HighlightedRow";
}
}