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

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Find out particular row form grid view using LINQ?

Posted By:Sajid P K       Posted Date: October 08, 2010    Points: 15    Category: LINQ    URL: http://www.dotnetspark.com  

Find out particular row form grid view using LINQ?

Summary: = Usually getting a row from Grid view, we will loop thou the grids row collection and check for   Specific conditions.


  GridViewRow SelectedRow;


   foreach (GridViewRow gr in GridView1.Rows)


       if ( gr.Cells[1].ToString() == "Value1"  &&  gr.Cells[2].ToString()  == "Value2")


             SelectedRow = gr;






But using LINQ we can write same thing as more readable manners as given below.


GridViewRow  SelectedRow = GridView1.Rows.OfType<GridViewRow>().FirstOrDefault(row => row.Cells[1].ToString() == "Value1" && row.Cells[2].ToString() == "Value2");


If you have any question  please post here ?


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