Generate multiple Gridviews with properties of another Gridview

dhaimy

New Member
I Have one gridview declared in ASP something like this:\[code\]<asp:GridView ID="GV_Sample" runat="server" AutoGenerateColumns="False" Visible="false" CssClass="tabela" style="margin: 0 auto;" UseAccessibleHeader="true" > <Columns> <asp:TemplateField HeaderText="Nome" HeaderStyle-CssClass="col1 column"> <HeaderTemplate> Nome </HeaderTemplate> <ItemStyle CssClass="col1 column" /> <ItemTemplate> <p><asp:Label ID="lbl_micro" runat="server" Text='<%# Bind("Descricao") %>' /></p> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Curso" HeaderStyle-CssClass="col2 column"> <HeaderTemplate> Curso </HeaderTemplate> <ItemStyle CssClass="col2 column" /> <ItemTemplate> <asp:HyperLink ID="link_micro" runat="server" Text='<%# "<span>"+ Eval("id") + "</span>" %>' NavigateUrl='<%# returnRawUrl() + "&id=" + Eval("id") %>' CssClass="linkBlock button-cursos" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>\[/code\]In code behind I want generate multiple Gridviews with all the properties of GV_Sample, and just change the DataSource:\[code\]for(int i=0; i<array.Count; i++){ GridView gvr = GV_Sample; gvr.id="myGV_"+i; SqlDosCursos.SelectParameters["ID"].DefaultValue = http://stackoverflow.com/questions/14052668/array; gvr.DataSourceID ="SqlDosCursos"; gvr.DataBind(); myPlaceHolder.Controls.Add(gvr);}\[/code\]The problem is only the last cycle of my for insert the GridView in the placeholder, all the other's who should be inserted are not there. How can I solve this?Thanks!
 
Back
Top