Hi,
I have a SPList in SP 2010. The list has three fields.
Image--- Publishing Image
Image Description---Single line of text
Checked Image--Boolean
I m using SPQuery to retrieve the Image and Image Description on my aspx page for CheckedImage.
How do I do it?
Here's my code but its not giving the result.
I created a usercontrol1.ascx that has
//usercontrol1.ascx.cs has got the code below in page load event.
if (currentWeb != null && currentWeb.Site.RootWeb != null)
{
if (pubPage != null && pubPage.Layout.Title == "Test Home Page Layout")
{
//Get the list
SPList FeaturedImage = currentWeb.List["FeaturedImageDetails"];
//Create a query
SPQuery query = new SPQuery();
query.Query = string.Format("<Where><Eq><FieldRef Name='ImageFeaturedHD' /<Value Type='Boolean'>1</Value></Eq></Where>");
//Get the list items
SPListItemCollection collListItems = FeaturedImage.GetItems(query);
string sUrl = "";
foreach (SPListItem Listitem in collListItems)
{
Microsoft.SharePoint.Publishing.Fields.ImageFieldValue h = (Microsoft.SharePoint.Publishing.Fields.ImageFieldValue)Listitem["Image"];
testImage.ImageUrl = h.ImageUrl;
testLabel.Text = Listitem["ImageDescHD"].ToString();
break;
}
testImage.ImageUrl = sUrl;
}
I have a SPList in SP 2010. The list has three fields.
Image--- Publishing Image
Image Description---Single line of text
Checked Image--Boolean
I m using SPQuery to retrieve the Image and Image Description on my aspx page for CheckedImage.
How do I do it?
Here's my code but its not giving the result.
I created a usercontrol1.ascx that has
//usercontrol1.ascx.cs has got the code below in page load event.
if (currentWeb != null && currentWeb.Site.RootWeb != null)
{
if (pubPage != null && pubPage.Layout.Title == "Test Home Page Layout")
{
//Get the list
SPList FeaturedImage = currentWeb.List["FeaturedImageDetails"];
//Create a query
SPQuery query = new SPQuery();
query.Query = string.Format("<Where><Eq><FieldRef Name='ImageFeaturedHD' /<Value Type='Boolean'>1</Value></Eq></Where>");
//Get the list items
SPListItemCollection collListItems = FeaturedImage.GetItems(query);
string sUrl = "";
foreach (SPListItem Listitem in collListItems)
{
Microsoft.SharePoint.Publishing.Fields.ImageFieldValue h = (Microsoft.SharePoint.Publishing.Fields.ImageFieldValue)Listitem["Image"];
testImage.ImageUrl = h.ImageUrl;
testLabel.Text = Listitem["ImageDescHD"].ToString();
break;
}
testImage.ImageUrl = sUrl;
}