Ok so i was bizzy with a datalist with a picture in it witch should be loaded like the ID was 22 then the picture would be http://localhost/picture/product/22.jpg but it could also be that there was no picture and then it should link it so http://localhost/picture/product/na.jpg the problem was how do you do this a well here is the way i did it.
The img was called “img_product” and was on the ItemTemplate now i whent to events and dubble clicked on ItemDataBound kicked me to the codebehind and made the function DataListProduct_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) so now i needed to access the image from the datalist. This was done by using:
Image image = e.Item.FindControl(“img_product“) as Image;
Now i could access the ImageUrl of the image by using:
image.ImageUrl = string.Format(“http://localhost/picture/product/{0}.jpg“, ID);
Here ID is na or the ID of the product.
So the way to acccess a control using ItemDataBound is e.Item.FindControl(“<ControlName>“).
Good Luck all and have fun :D