Probleme ContentPlaceHolder vide
Bonsoir,
J'ai un soucis de contentplaceholder. En effet ce dernier, créé à la main sur mon aspx de la façon suivante :
Code:
<asp:PlaceHolder ID="phGrids" runat="server"></asp:PlaceHolder>
et rempli dynamiquement par la procédure suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| foreach( DataRow vue in dt_views.Rows)
{
//nouvelle grid view
GridView tmpGW = new GridView();
//nouveau label
Label lblTmp = new Label();
lblTmp.Text = vue["TABLE_NAME"].ToString();
lblTmp.CssClass = "TableTitle";
tmpGW.ID = "gw_" + vue["TABLE_NAME"].ToString();
//requete sql pour la liste des vues stockée dans un tableau de strings
SqlCommand tmpQuery = new SqlCommand("Select * FROM " + vue["TABLE_NAME"].ToString(), maConnex);
SqlDataReader reader = tmpQuery.ExecuteReader();
//pour chaque vue, un reader est bindé sur la gridview
tmpGW.DataSource = reader;
tmpGW.DataBind();
//partie css
tmpGW.CssClass = "Grid";
tmpGW.HeaderStyle.CssClass = "GridHeader";
tmpGW.RowStyle.CssClass = "GridItem";
tmpGW.AlternatingRowStyle.CssClass = "GridAltItem";
//Ajout de la grid et du label au contentplaceholder
phGrids.Controls.Add(lblTmp);
phGrids.Controls.Add(new HtmlGenericControl("br"));
phGrids.Controls.Add(tmpGW);
phGrids.Controls.Add(new HtmlGenericControl("br"));
reader.Dispose();
} |
A l'éxécution, il m'affiche mes gridview, mais au clic sur un bouton :
Code:
1 2 3
| <asp:Button ID="btSaveXls" runat="server" onclick="Button1_Click"
Text="Export XLS" Width="100%" CausesValidation="False"
UseSubmitBehavior="False" /> |
ce bouton me permettant l'export au fichier csv, surprise, mon phGrids.Controls est vide .... :s
auriez vous une piste pour m'aider ? en vous remerçiant !