Yes, I did that. But actually, those two piece of code did not even fire up any events the first time called.
--- Rajendra Appalla <[EMAIL PROTECTED]> wrote: > Are you adding those two columns again in PostBack?? > Because you > should. The known behavior if you don't add those > columns again in > postback is that the events won't fire on those > columns. > > Rajendra. > > -----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 > click here > <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/*htt > p:/companion.yahoo.com> > > <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=group > s/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] > cribe> > > * 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] > > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/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/
