0
可能重复:
How to highlight the results of a text in a gridview?如何突出显示gridview中文本的结果?
我问过许多times..I得到了答案,但我不知道该怎么做.. 我有搜索文本框一个文本里面的gridview表..但我不知道该怎么做..请帮助我 sql database 2008,asp.net,c#
可能重复:
How to highlight the results of a text in a gridview?如何突出显示gridview中文本的结果?
我问过许多times..I得到了答案,但我不知道该怎么做.. 我有搜索文本框一个文本里面的gridview表..但我不知道该怎么做..请帮助我 sql database 2008,asp.net,c#
你可以用Dataview Rowfilter重新填充你的Gridview来搜索..
.....
.....
DataView dvData = new DataView(yourDataTableGoesHere);
dvData .RowFilter = "Name LIKE 'j*'"
DGV.DataSource = dvData;
DGV.DataBind();
使用jQuery搜索
string SearchString = "";
protected void Page_Load(object sender, EventArgs e)
{
txtSearch.Attributes.Add("onkeyup", "setTimeout('__doPostBack(\'" + txtSearch.ClientID.Replace("_", "$") + "\',\'\')', 0);");
if (!IsPostBack)
{
Gridview1.DataBind();
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
SearchString = txtSearch.Text;
}
public string HighlightText(string InputTxt)
{
string Search_Str = txtSearch.Text.ToString();
// Setup the regular expression and add the Or operator.
Regex RegExp = new Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
// Highlight keywords by calling the
//delegate each time a keyword is found.
return RegExp.Replace(InputTxt, new MatchEvaluator(ReplaceKeyWords));
// Set the RegExp to null.
RegExp = null;
}
public string ReplaceKeyWords(Match m)
{
return "<span class=highlight>" + m.Value + "</span>";
}
时要突出一个DataGridView我想强调的文本 – 2012-03-03 16:41:18