.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to display Searched Records in Highlight way inside GRIDVIEW ?

Posted By: susant     Posted Date: November 02, 2008    Points:2   Category :ASP.Net
Hello

Suppose I have one Gridview and its displaying Records like..

1 susant 28 Banglore
2 pop 23 Delhi
3 Haris 90 Banglore
4 Nitesh 26 Hyderbad
5 Jien 45 Banglore

One TextBox is there for search i typed to search: Banglore

Requirements:

so it should highlight 3records, Record No: 1,3,5 In the GRIDVIEW

How to Highlight the searched records in GirdView??


ThanX & Regards

susant(9916351611)
susantaown@gmail.com

Responses
Author: Rahul             
Posted Date: November 02, 2008     Points: 5   

Hi,
Try like this

protected void Button1_Click(object sender, EventArgs e)

{

string searchString = txtSearch.Text;

StringBuilder sb = new StringBuilder();

DataTable dt = new DataTable();

List<GridViewRow> rows = new List<GridViewRow>();



foreach (GridViewRow row in GridView1.Rows)

{

TableCellCollection cells = row.Cells;

foreach (TableCell cell in cells)

{

if (cell.Text.ToLower().StartsWith(searchString.ToLower()))

{

cell.BackColor = System.Drawing.Color.Yellow;


foreach (TableCell c in cells)

{

sb.Append(c.Text);


}


sb.Append("<BR>");


}

else

{

cell.BackColor = System.Drawing.Color.White;

}

}

}
}



http://aspadvice.com/blogs/azamsharp/archive/2006/10/02/Searching-in-the-GridView-Control.aspx

Author: Santosh             
Posted Date: October 19, 2009     Points: 5   

hi Sushant
Plz follow below link of this website

http://www.dotnetspark.com/kb/Content.aspx?id=942

Regards
Santosh



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend