如何突出在GridView文本的结果吗? [英] How to highlight the results of a text in a gridview?
本文介绍了如何突出在GridView文本的结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
我如何能突出
我有一个GridView和用于从列搜索文本的文本框。
我怎么能突出显示栏中的文本的结果。
我已经搜查和询问,我得到坚硬的东西,以code..would有人给我一个简单的code的东西吗?谢谢
I have a gridview and a textbox for searching text from a column. How can I highlight the result of the text in the column. I've searched and asked and I get hard things to code..would someone give me a simple code something ? thanks
推荐答案
我可以给你一个例子。
让说,搜索框是:
txtSearchForMe.Text
然后你就向您展示赢得了突出的数据网格领域
Then you make the field on the Grid that show the data you won to highlight
<asp:TemplateField HeaderText="Text" >
<ItemTemplate ><%#GetText(Container.DataItem)%></ItemTemplate>
</asp:TemplateField>
和背后
protected string GetText(object oItem)
{
if(txtSearchForMe.Text.Lenght > 0)
{
return DataBinder.Eval(oItem, "cText").Replace(txtSearchForMe.Text, "<b>" + txtSearchForMe.Text + "</b>");
}
else
{
return DataBinder.Eval(oItem, "cText");
}
}
这是一个简单的想法,你可以把它更受夹板搜索字符串分隔话阵列复杂化,并强调他们。
This is a simple idea, you can make it more complicate by splinting the search string to array of separated words and highlight them all.
这篇关于如何突出在GridView文本的结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文