Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems Using DropDownList inside an ItemTemplate
Message
Information générale
Forum:
ASP.NET
Catégorie:
WebForms
Divers
Thread ID:
01307922
Message ID:
01308017
Vues:
13
>Hi All.
>
>I must have tajen my stupid pills today because I don't understand why this does not work. Any help would be appreciated.
>
>
>ddl is null. But is I run the form without trying to populate the dropdown list, an empty dropdownlist shows up in the grid column, so I know it is there.
>
>Any ideas?

The RowDataBound fires more often than you might think (even when there isn't data in the row - think header rows, etc.). I usually follow this format when I need to do something similar:
DropDownList ddl = e.Row.FindControl("ddlType") as DropDownList;
if (ddl != null)
   // Do something
Having said that, I would probably opt for a user control for the dropdown list, then add that to the column. That makes it easy to do things like enable output caching on that specific control (esp. if the contents don't change on every row) so you don't end up having to hit the database on every row in the table.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform