Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Iterate GridView Values
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01456635
Message ID:
01456723
Vues:
45
>>>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;
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform