Being new to ASP.Net but ok with winForm I rather naively thought I could create an image button on the fly and put an image on it (rather than an ImageURL).

The problem is this -

I want to create an imagebutton in my gridview. I am placing this in at design time and each row needs a custom image based on some values in the row. No problem with creating the image (using GDi+) but assigning it to the button seems impossible.

If ImageButton had an 'image' property then this would be trivial. However, it only has an ImageURL. I suppose that I could create the image, save it on the server and then reference it, but this would be difficult and messy to clean up. I have tried to understand how I might use a webmethod to serve the image, but this also seems expensive for a table of 30-40 rows - I would prefer to set the images before they are sent to the server....

Solution 2

I have not really found an acceptable solution - the sub optimal solution works, but the page takes ages to load each image. In the end I created images for each criteria - 400 images - and referenced these.