473,395 Members | 1,537 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,395 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 9600
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.