Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iterate GridView Values
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Iterate GridView Values
Miscellaneous
Thread ID:
01456635
Message ID:
01456635
Views:
85
I have a GridView on my page with 3 columns, RightKey, AllowDeny, and Caption. AllowDeny is a checkbox. When Saved is clicked I
want to iterate through all rows and get these 3 values. So far I have:
foreach (GridViewRow Row in grdRights.Rows)
{
    CheckBox cb = (CheckBox)Row.FindControl("chkAllowDeny");
}
But the other 2 columnd are bound, and there's no public ID property. So how do I get the values of these two columns?

I'm sure it's something like
TextBox txt= (TextBox)Row.FindControl(-- name here --);   
But if I can't set the ID, then what's the name?

I also tried
string textBoxText = ((TextBox)Row.FindControl(Row.Controls[0].ID)).Text;
But it errors with "Object reference not set to an instance of an object"
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform