I want to connect picture library with a webpart. I have 3 light as pictures (green, yellow and red) for commands. I want to have the most simple way to make a command ( for example: process is completed and then it shows green light) and apply it on picture.
if its in a webpart why are you not storing the images (i presume they are allways green,orange and red) within styles library?
within your code have a function that checks and changes the image accordingly?
if your insistant on the doc library and you know its the same values everytime than do:
SPWeb Web = SPContext.Current.Web; SPPictureLibrary pictures = (SPPictureLibrary)web.Lists["my home Photos"];
the above needs to be within creatchildcontrols or called from. After that you can so somthing like:
string sourceurl = Web.Url + "/" + pictures.Items[index].Url; this.Controls.Add(new LiteralControl("<img src='" + sourceurl + "' height='200' />");
above needs to also be within creatchildcontrols ;) , index refers to the item number within the list! so if you have green orange red that would be (0) green, (1) orange, (2) red.