For Programmers: Free Programming Magazines  


Home > Archive > C# > June 2004 > how to add click function to dynamically created Button in WebForm?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to add click function to dynamically created Button in WebForm?
teddy

2004-06-03, 7:31 pm

Hi,

I am trying to create a bookstore application using c#. I can display
the books (obtained from sql server) on a table. 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 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,

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com