Looping through gridview in C# always return empty

I had a gridview which was bounded to a datasource (datatable in my case) in code behind in C#. Code was something like this

This was always returning empty (”) no matter which column index I was pointing to. I tried different variations like

but it failed too. After pondering on it for quite a while and still not resolved, I decided to loop through the data source itself, in my case a datatable. That actually worked! That code looks like this

I am still not sure why it will not read the values from GridView in a loop but at least there is work around.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*