Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get grid view column values while looping?
Message
From
23/06/2008 15:05:47
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326177
Message ID:
01326185
Views:
24
>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?



My guess is that you simply use row["LastName"].....etc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform