472,102 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

ImageButton click even refuses to fire

I have set up a page with uses two lots of image buttons, one for a collection and one for more images from that collection.

I generate all the image buttons on page init (I know, but I implemented that as part of trying to solve this already existant problem).

The CollectionItemButton_Click event will fire, but the MoreImagesButton_Click will

I just don't get it. Someone, somewhere told me that I have to reassociate event on
Page_Load... this can't be right can it? Help!

If you need any more information please ask - the code follows.

--> Oddball

++++ START CODE ++++

// Create a new ImageButton for the main collection
ImageButton newImageButton = new System.Web.UI.WebControls.ImageButton();

// Set the URL to the relevent thumbnail image
newImageButton.ImageUrl = "/thumbnail.aspx?id=" + fiRow[ADM.IMAGEID_FIELD] +

// And give it the right CSS class
newImageButton.CssClass = UNSELECTED_CLASS;

// Use CommandName and CommandArgument to store data
newImageButton.CommandName = "" + seats;
newImageButton.CommandArgument = fRow[ADM.FURNITUREID_FIELD].ToString();

// Associate the event (this one works!!!)
newImageButton.Click += new ImageClickEventHandler(CollectionItemButton_Click) ;

// Now get the images for that piece
DataTable fTab = Catalogue.Tables[ADM.FURNITURE_TABLE];
// Get an array of FurnitureImage rows
fiRowArray =

// Create the array that will hold the MoreImages
ImageButton[] NewMoreImagesArray = new ImageButton[fiRowArray.Length];

// Counter for counting stuff
int count = 0;

// Right - work through each furniture image row and create a button for it
foreach (DataRow fimiRow in fiRowArray)
// One blank button - ready to go
ImageButton iB = new System.Web.UI.WebControls.ImageButton();

// Set to the thumbnail
iB.ImageUrl = "/thumbnail.aspx?id=" + fimiRow[ADM.IMAGEID_FIELD] +

// Set the class

// Data
iB.CommandName = "" + seats;
iB.CommandArgument = fRow[ADM.FURNITUREID_FIELD].ToString();

// Associate the MoreImages event ( THIS DOES NOT WORK!!! )
iB.Click += new ImageClickEventHandler(MoreImagesButton_Click);

// And add the button to the array....
NewMoreImagesArray[count] = iB;

// Count something

// Add all this gubbins to the correct arrays
CollectionItemsArray[seats] = newImageButton;
MoreImagesArray[seats] = NewMoreImagesArray;

++++ END CODE ++++

Another unchecked rambeling brought to you by:

Nov 19 '05 #1
0 1424

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by angus | last post: by
1 post views Thread by MattB | last post: by
3 posts views Thread by TCORDON | last post: by
reply views Thread by Tom Edelbrok | last post: by
reply views Thread by Yourself | last post: by
4 posts views Thread by suzanne.boyle | last post: by
reply views Thread by leo001 | 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.