I am doing custom visual web part(Sandboxed) developement. I am facing a little hurdle as I unable to retrieve Title, Image and URL columns from my custom list and bind it to a repeater control. Also how to bind the URL to Image on click.My CAML query selects values based on another column if its value is less than 5. Please provide your suggestions.I am just beginning with SP2010 Development, so really appreciate your help. Cheers :)
My Ascx.cs code
SPList list = web.Lists[listName.ToString()];
//Getting the latest folder in the list
string serverPath = web.Url.ToString();
SPQuery query = new SPQuery();
query.Query = @"<Where><Leq><FieldRef Name='ItemOrder' /><Value Type='Number'>5</Value></Leq></Where><OrderBy><FieldRef Name='ItemOrder' Ascending='True' /></OrderBy>";
query.RowLimit = 5;
SPListItemCollection itemColl = list.GetItems(query);
bool allowUpdates = web.AllowUnsafeUpdates; //store original value
web.AllowUnsafeUpdates = true;
if (itemColl.Count > 0)
{
foreach (SPListItem item in itemColl)
{
rptTitle.DataSource = itemColl.Fields["Title"];
rptTitle.DataBind();
rptImage.DataSource = itemColl.Fields["Image"];
rptImage.DataBind();
//hplViewAll.NavigateUrl = web.ServerRelativeUrl;
}
}
else
{
UserFriendly("No items to Display");
}
web.AllowUnsafeUpdates = allowUpdates;
}
I am sorry, my bad. I am trying to display both Image and title from my custom list. I have two repeaters for which I would have to map my source. MY ASCX CODE
<%# ((Carousel)Container.DataItem).Title %> " alt=""/>