Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Professional C#, 2nd and 3rd Editions
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 4th, 2005, 02: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";
tblCell[0].Controls.Add(SelButton);
// add remaining cells
tblRow.Cells.AddRange(tblCell);
Table1.Rows.Add(tblRow);

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

Any and all help is welcomed.


Reply With Quote
  #2 (permalink)  
Old March 4th, 2005, 02:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

SelButton.Click += new EventHandler(SelButton_Click);

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

Brian
Reply With Quote
  #3 (permalink)  
Old March 4th, 2005, 03:26 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:TableRow>
 <asp:TableCell>
  <asp:Button OnCommand="CommandBtn_Clicked" Width="20px" Runat="server"></asp:Button></asp:TableCell></asp:TableRow>


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01: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



All times are GMT -4. The time now is 01:06 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.