I have a SPList which has three fields: Image that holds Url of the publishing image and ImageDescription that holds a single line of text for description and a checkbox field called ImageChecked(yes/NO)
The probelm is if the checkbox is selected, it should display the image and the ImageDescription on the aspx page. Ideally there is only one item in the list with checkbox yes.
I m using SPQuery to query the list.
Here's how I did it. However its not giving me the result I wanted. I created a usercontrol1.ascx that has
//usercontrol1.ascx.cs has got the code below in page load event.
//Get the list
SPList HomepageImage = currentWeb.Lists["My Images"];
//Create a query
SPQuery query = new SPQuery();
query.Query =string.Format("1");
//Get the list items
SPListItemCollection collListItems = My Images.GetItems(query);
string sUrl = "";
foreach (SPListItem Listitem in collListItems)
{
Microsoft.SharePoint.Publishing.Fields.ImageFieldValue h = (Microsoft.SharePoint.Publishing.Fields.ImageFieldValue)Listitem["Image"];
//Image control
testImage.ImageUrl = h.ImageUrl;
testImage.ImageUrl = sUrl;
//Label control
testLabel.Text = Listitem["ImageDescHD"].ToString();
break;
}
Any thoughts to achieve this? Thanks.