Please bear with me as I am brand new to the whole sharepoint world. I want to be able to display images that have been attached to OOTB announcement list in a custom visual web part I am trying to build. I would also like to be able to show the title (from the list) right under the image as a hyperlink (I am thinking I would have to convert it after retrieving it from the list) I want to display three images in a row with some spacing in between them. Here is the code I have as of now:
using (SPSite oSPsite = new SPSite("http://sharepointdev:2000/"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
oSPWeb.AllowUnsafeUpdates = true;
// Fetch the List
SPList list = oSPWeb.Lists["Announcements"];
SPQuery spQuery = new SPQuery();
spQuery.Query = "<Where> <Eq> <FieldRef Name='Title' /> <Value Type='Text'></Value> </Eq> </Where>";
spQuery.Query = "";
spQuery.RowLimit = 3;
// Show item in text box
SPListItemCollection oListCollection = list.GetItems(spQuery);
foreach (SPListItem item in oListCollection)
{
ListBox1.Items.Add(item.Title);
}
}
