Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   How to add click function to a dynamically created Button in WebFormapplication? (http://www.velocityreviews.com/forums/t794307-how-to-add-click-function-to-a-dynamically-created-button-in-webformapplication.html)

teddy 05-05-2004 06:46 PM

How to add click function to a dynamically created Button in WebFormapplication?
 

I am trying to create a bookstore WebApplication using c#. I can
display the books (obtained from sql server) on a table in a WebForm.
At the end of each row, I would like to add "add to cart" button.
Therefore, I use

Button bt_add = new Button();
bt_add.Text = "Add to cart";

and put it in a cell which is later placed in each table row. The
Buttons display fine on the WebForm. However, I don't know how to add
the Button_Click function for each of the Button I created since I don't
know the total number of books in advance. Can anyone help me get "add
to cart" button to work?

Note: I try clicking on each Button, the WebForm page loads back to its
original stage (Page_Load function) and my search result is gone.

Thanks,


Aaron Bertrand - MVP 05-05-2004 06:52 PM

Re: How to add click function to a dynamically created Button in WebForm application?
 
http://www.aspfaq.com/5002

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"teddy" <teddy@ee.columbia.edu> wrote in message
news:c7bcoh$c2$1@newsmaster.cc.columbia.edu...
>
> I am trying to create a bookstore WebApplication using c#. I can
> display the books (obtained from sql server) on a table in a WebForm.
> At the end of each row, I would like to add "add to cart" button.
> Therefore, I use
>
> Button bt_add = new Button();
> bt_add.Text = "Add to cart";
>
> and put it in a cell which is later placed in each table row. The
> Buttons display fine on the WebForm. However, I don't know how to add
> the Button_Click function for each of the Button I created since I don't
> know the total number of books in advance. Can anyone help me get "add
> to cart" button to work?
>
> Note: I try clicking on each Button, the WebForm page loads back to its
> original stage (Page_Load function) and my search result is gone.
>
> Thanks,
>





All times are GMT. The time now is 05:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.