Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional C#, 2nd and 3rd Editions
This is the forum to discuss the Wrox book Professional C#, 3rd Edition by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen; ISBN: 9780764557590
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C#, 2nd and 3rd Editions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 4th, 2005, 03:07 PM
Registered User
Join Date: Sep 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Button Generation

Iam building a dynamic table with 5 cells. The first cell will be a button to be used to select that row. I am not having a problem creating the table row by row. However I can not figure out how to capture the event when the button in cell is pressed.
code sample
TableRow tblRow = new TableRow();
TableCell[] tblCell - new TableCell[5];
tblCell[0] = new TableCell();
tblCell[1] = new TableCell();
tblCell[4] = new TableCell();

SelButton = new Button();
SelButton.ID = "SelBtn";
SelButton.CommandArg = "Select";
// add remaining cells

I can not figure out how I dynamically add the
'OnCommand = "CommandBtn_Clicked" ' to the button.

Any and all help is welcomed.

Old March 4th, 2005, 03:40 PM
Friend of Wrox
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts

SelButton.Click += new EventHandler(SelButton_Click);

Define an event SelButton_Click in your code then. Or you may have to look at event bubbling.

Old March 4th, 2005, 04:26 PM
Registered User
Join Date: Sep 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks but that did not work.

If I put the following line in the aspx file it works, I need to put this line in dynamically.

  <asp:Button OnCommand="CommandBtn_Clicked" Width="20px" Runat="server"></asp:Button></asp:TableCell></asp:TableRow>

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic PDF Generation sandyg Classic ASP Components 12 June 15th, 2008 03:51 AM
Dynamic textbox generation into gridview dharmeshtandel ASP.NET 2.0 Basics 3 December 24th, 2007 02:14 AM
Dynamic generation of .Net button in a position sonaldewle General .NET 0 April 3rd, 2006 03:51 AM
Dynamic ASP button generation Lloyd_Christmas Classic ASP Basics 1 May 17th, 2005 06:50 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.