Question: I am new to selenium. I want to verify data shown in grid on my web application page with database value.

I have gone through blogs, and what I have found is:

Using *Selenium Webdriver* in C#:

i. Connect to database and execute the query and get data.  

ii. Get parent element of data shown on screen and loop through its child element and match the data.

Is there any better way available to validate data (let's say data in grid) shown on web page with database using *selenium webdriver?*

Using IDE: I have searched for this but I have not found any way to connect selenium IDE with database (in my case, SQL Server).

Let me know if I have missed something or misunderstood the concept.

Regards.

Answer: 
We did it the same way using C#. Unless it is really slow I would leave it like this. 
The only suggestion I would have would be to give each cell a unique identifier so you can use the quick "by id" locator. 

You could also check that the MAX+1 rows / columns don't exist if you want to be really rigorous.
I had come across a similar issue . When I inspected the DOM for both List and Grid View , I found classes with the view name . I then asserted if the classes were present . This ensures the view is either grid view or list view