|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamically adding DataGrid columnsDoes anyone know how to add columns dynamically to a DataGrid. i populate the grid using the .ItemDataBound the current structure of my grids are as below.... <asp:templatecolumn> <headertemplate> <asp:label id="lblDisp" runat="server" text="" tooltip="" /> </headertemplate> <itemtemplate> <asp:label id="lblSales" runat="server" cssclass="GridTDText"></asp:label> <br /> <asp:label id="lblProfit" runat="server" cssclass="GridTDText"></asp:label> <br /> <asp:label id="lblMargin" runat="server" cssclass="GridTDText"></asp:label> </itemtemplate> <edititemtemplate> <asp:textbox id="txtSales" runat="server" cssclass="GridTextBox Small" ></asp:textbox> <br /><asp:textbox id="txtProfit" runat="server" cssclass="GridTextBox Small"></asp:textbox> <br /> <asp:textbox id="txtMargin" runat="server" cssclass="GridTextBox Small"></asp:textbox> </edititemtemplate> </asp:templatecolumn> One approach is to simply add an extra column to your dataset and then bind
the dataset to the datagrid. The extra column would then show up automatically. -- Show quoteHide quoteRegards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ http://tinyurl.com/27cok ---------------------------------------------------------- "Ian Oldbury" <ian_oldbury@_NO_msn_SPAM_.com> wrote in message news:%23ui3a3cDFHA.1260@TK2MSFTNGP12.phx.gbl... > Hi, > > Does anyone know how to add columns dynamically to a DataGrid. > > i populate the grid using the .ItemDataBound > > the current structure of my grids are as below.... > > <asp:templatecolumn> > <headertemplate> > <asp:label id="lblDisp" runat="server" text="" tooltip="" /> > </headertemplate> > <itemtemplate> > <asp:label id="lblSales" runat="server" > cssclass="GridTDText"></asp:label> > <br /> > <asp:label id="lblProfit" runat="server" > cssclass="GridTDText"></asp:label> > <br /> > <asp:label id="lblMargin" runat="server" > cssclass="GridTDText"></asp:label> > </itemtemplate> > <edititemtemplate> > <asp:textbox id="txtSales" runat="server" cssclass="GridTextBox Small" > ></asp:textbox> > <br /> > <asp:textbox id="txtProfit" runat="server" cssclass="GridTextBox > Small"></asp:textbox> > <br /> > <asp:textbox id="txtMargin" runat="server" cssclass="GridTextBox > Small"></asp:textbox> > </edititemtemplate> > </asp:templatecolumn> > |
|||||||||||||||||||||||