473,226 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Dynamic Button Controls and Click Events

Hello,
I am having a little problem. I have create a very basic shopping cart
site. In the process of displaying items in the shop, I am using image
buttons so that you may click on them and display detailed information
for that item, and another button which allows you to add the item to
your shopping cart. However, for some reason the events do not fire
correctly, or when they do it seems that it is the prior buttons
properties which are passed to the event handeler for that button. I
was wondering if anyone could help me with what it is I am doing wrong.
Thank you all in advance for your help.

Alex.

Example of the button being added, i use the id to determin the id of
the item click so that i can pull the correct data from the database.

ImageButton imgBut = new ImageButton();
iNormCount ++;
imgBut.ID = "imgBut" + iNormCount.ToString() + "-" +
drRow[dbDef.Df_tbl_DShop.fitbl_DShop.ID].ToString();
imgBut.CommandArgument =
drRow[dbDef.Df_tbl_DShop.fitbl_DShop.ID].ToString();
imgBut.Width = 96;
imgBut.Height = 115;
imgBut.ImageUrl = sImageURL;
imgBut.EnableViewState = true;
imgBut.Click +=new ImageClickEventHandler(imgBut_Click);

pnlPanel.Controls.Add(imgBut);

*** Sent via Developersdex http://www.developersdex.com ***
Nov 27 '05 #1
1 9595
You may want to check http://www.denisbauer.com/ASPNETCont...aceholder.aspx
Gokhan Altinoren
gokhan[RMV_this][at]altinoren[also_RMV_this][dot]com
http://altinoren.com
Hello,
I am having a little problem. I have create a very basic shopping
cart
site. In the process of displaying items in the shop, I am using
image
buttons so that you may click on them and display detailed information
for that item, and another button which allows you to add the item to
your shopping cart. However, for some reason the events do not fire
correctly, or when they do it seems that it is the prior buttons
properties which are passed to the event handeler for that button. I
was wondering if anyone could help me with what it is I am doing
wrong.
Thank you all in advance for your help.
Alex.

Example of the button being added, i use the id to determin the id of
the item click so that i can pull the correct data from the database.

ImageButton imgBut = new ImageButton();
iNormCount ++;
imgBut.ID = "imgBut" + iNormCount.ToString() + "-" +
drRow[dbDef.Df_tbl_DShop.fitbl_DShop.ID].ToString();
imgBut.CommandArgument =
drRow[dbDef.Df_tbl_DShop.fitbl_DShop.ID].ToString();
imgBut.Width = 96;
imgBut.Height = 115;
imgBut.ImageUrl = sImageURL;
imgBut.EnableViewState = true;
imgBut.Click +=new ImageClickEventHandler(imgBut_Click);
pnlPanel.Controls.Add(imgBut);

*** Sent via Developersdex http://www.developersdex.com ***

Nov 27 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4...
1
by: hybrid | last post by:
I have problems in understanding the behavior of the events triggered by dynamically created controls over a webform. Could you help me? In a webform, I have a static PlaceHolder PH containing...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
0
by: Michael Ramey | last post by:
Hello, I'm trying to handle click events with button controls I've created dynamically. I've found two ways of dealing with them, neither of which I like, so I'm asking if anyone knows a better...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
4
by: Fueled | last post by:
Hi everyone! I've made quite a lot of research on this, and I've tried a couple of proposed solutions. Nothing has worked for me, but I feel there's not much I'm missing. So I'm turning to this...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.