I have custom List which has image field. I have to display the image through the object modelling code.
Which Control I need to use to display the image in a webpart and which property I need to assign it for.
[Guid("207cea76-b1ee-4b86-9638-00c22d3d9398")]
public class News : System.Web.UI.WebControls.WebParts.WebPart
{
Label lblTitle;
ImageField imgNews;
Label lblDescription;
public News()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
lblTitle = new Label();
imgNews = new ImageField();
lblDescription = new Label();
string siteURL = "http://my-dev-box-har";
using (SPSite site = new SPSite(siteURL))
{
using (SPWeb web = site.OpenWeb())
{
SPListItemCollection list = web.Lists["News"].Items ;
foreach (SPListItem item in list)
{
lblTitle.Text = item["Title"].ToString();
lblDescription.Text = item["Description"].ToString();
imgNews. = item[""].ToString();
Controls.Add(lblTitle);
Controls.Add(lblDescription);
}
}
}
}
}
}
I don't know wheather to use image or Imagefield control to display my image form the sharepoint custom list.
Could anybody point me in right direction please.
Thank you Hari