Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iterate GridView Values
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01456635
Message ID:
01456677
Views:
48
>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?

If you don't give it an ID then it simply won't have a 'name'
What prevents you providing IDs ?

>
>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"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform