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

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Search within Gridview Not in database.

Posted By:Hiren Soni       Posted Date: August 29, 2010    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Search within Gridview Not in database.

Search all rows and columns of gridview from gridview, not searching from the database.

Search within Gridview based on search criteria

In other forum, one user asked me to search within Grid view , and its display only those rows which match with the search criteria. so I given some code like this:

Code Snippet :

// iterate through all rows

for (int j = 0; j < GridView1.Rows.Count; j++)


// iterate through all cols

for (int i = 0; i < GridView1.Columns.Count; i++)


//match each cell of row with search value

if (GridView1.Rows[j].Cells[i].Text.Contains("search criteria"))


//set visible true if match with criteria

GridView1.Rows[j].Cells[i].Visible = true;





//set visible false if match with criteria

GridView1.Rows[j].Cells[i].Visible = false;





Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

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