Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get grid view column values while looping?
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
How to get grid view column values while looping?
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326177
Message ID:
01326177
Views:
166
Hi everybody,

I'm trying to figure out a syntax to get column values in a GridView while iterating through its rows.

Here is what I'm trying unsuccessfully:
  GridViewRow row = null; 
            for (int i = 0; i < this.ProfilesGrid.Rows.Count; i++ )
            {
                row = this.ProfilesGrid.Rows[i];
                CheckBox chkbtnApproved = row.FindControl("chkApproved") as CheckBox ;

                if (chkbtnApproved != null)
                {
                    if (chkbtnApproved.Checked == true)
                    {
                        int RegID = (int)this.ProfilesGrid.DataKeys[i].Value ;
                        
                        PersonName = row.DataItem["FirstName"].ToString() + " " + row.DataItem["LastName"].ToString(); // Here is an error Error	113	Cannot apply indexing with [] to an expression of type 'object'	
How can I construct Person Name in a loop?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform