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:
01456677
Vues:
49
>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"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform