471,337 Members | 1,115 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 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 9513
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by MikeY | last post: by
1 post views Thread by Jonathan Yong | last post: by
1 post views Thread by hybrid | last post: by
reply views Thread by Michael Ramey | last post: by
13 posts views Thread by Chris Thunell | last post: by
3 posts views Thread by Leo J. Hart IV | last post: by
4 posts views Thread by Fueled | last post: by
reply views Thread by rosydwin | last post: by

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.