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:
01456732
Views:
41
>>>>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 ?
>>
>>When I try this:
>>
>>
>><asp:BoundField ID="RightName" DataField="RightName" HeaderText="Right Name" />
>>
>>
>>I get a compiler exception saying ID is not a public property for a BoundField.
>
>Ah. Fair enough. Since you pretty much know the layout of the grid can't you just use something like:
MyTextBox.Text = Row.Cells[0].Text;
Yup. Then I realized how little I know about ASP when this returned an empty string because the column was invisible.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform