There is a great article on www.4guysfromrolla.com about the use of datagrids that cover editing, and all sorts of stuff, I use it for reference all the time. the article can be found at http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
George Oakes VB.Net Programmer/Analyst Morgan Tire & Auto dba. Tires Plus, Total Car Care (727) 442-8388 ext. 2374 (800) 269-4424 Toll Free [EMAIL PROTECTED] -----Original Message----- From: Psychomaniac [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 22, 2004 5:39 AM To: [EMAIL PROTECTED] Subject: [AspNetAnyQuestionIsOk] Dynamic Datagrids Hi, I'm trying to build an ASP.NET display page using datagrid. This datagrid must contain: ButtonColumn & EditCommandColumn. This is part of my code: <asp:DataGrid id="ItemsGrid" BorderColor="black" BorderWidth="1" CellPadding="3" OnEditCommand="ItemsGrid_Edit" OnCancelCommand="ItemsGrid_Cancel" OnUpdateCommand="ItemsGrid_Update" OnItemCommand="ItemsGrid_Command" AutoGenerateColumns="false" runat="server"> <HeaderStyle BackColor="#aaaadd"> </HeaderStyle> <Columns> <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" HeaderText="Edit item"> <ItemStyle Wrap="False"> </ItemStyle> <HeaderStyle Wrap="False"> </HeaderStyle> </asp:EditCommandColumn> <asp:ButtonColumn HeaderText="Delete item" ButtonType="LinkButton" Text="Delete" CommandName="Delete"/> Note that I also have defined "ItemsGrid_Edit", "ItemsGrid_Cancel", "ItemsGrid_Update" and "ItemsGrid_Command" in my VB code. It all works fine. However, I want to create the ButtonColumn & EditCommandColumn dynamically (i.e. during run-time). So I removes those 2 pieces of ASP code (asp:ButtonColumn & asp:EditCommandColumn) from the aspx, and in my VB code, I add this: Dim btnColumn As New ButtonColumn btnColumn.ButtonType = ButtonColumnType.LinkButton btnColumn.HeaderText = "Delete item" btnColumn.Text = "Delete" btnColumn.CommandName = "Delete" Dim editColumn As New EditCommandColumn editColumn.HeaderText = "Edit Item" editColumn.ButtonType = ButtonColumnType.LinkButton editColumn.UpdateText = "Update" editColumn.CancelText = "Cancel" editColumn.EditText = "E" editColumn.ItemStyle.Wrap = False ItemsGrid.Columns.Add(btnColumn) ItemsGrid.Columns.Add(editColumn) At first, it displays the grid correctly, however, when I click on "Delete" or the "Edit" link button, it never raises the event OnDeleteCommand nor OnEditCommand! Has anybody experienced this kind of problem as well? Thanks a lot! Adrian __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail Yahoo! Groups Sponsor ADVERTISEMENT <http://us.ard.yahoo.com/SIG=129ap372f/M=295196.4901138.6071305.3001176/D=groups/S=1705006764:HM/EXP=1095932372/A=2128215/R=0/SIG=10se96mf6/*http://companion.yahoo.com> click here <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=166831207> _____ Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
