How are custom fields in Lists modules accessed through code behind?
We have created a custom field in a List called "ImageIcon". We also have a user control imported as a custom widget called Header.ascx. I would like to know how to access the custom field from the code behind.
Here is the code I have so far:
private
void
setLogoImage()
String myPageName = Request.Url.Segments[Request.Url.Segments.Length - 1].Split(
'?'
)[0].ToLower();
ListsManager manager = ListsManager.GetManager();
Telerik.Sitefinity.Lists.Model.ListItem currentItem = manager.GetListItems()
.Where(i => i.UrlName == myPageName)
.FirstOrDefault();
if
(currentItem !=
null
)
imgMainLogo.ImageUrl = currentItem.?????
I was able to answer my own question. I was missing a using statement necessary for the GetValue method.
Here's my modified code:
using
Telerik.Sitefinity.Model;
//<---Forgot this
private
void
setLogoImage()
String myPageName = Request.Url.Segments[Request.Url.Segments.Length - 1].Split(
'?'
)[0].ToLower();
ListsManager manager = ListsManager.GetManager();
Telerik.Sitefinity.Lists.Model.ListItem currentItem = manager.GetListItems()
.Where(i => i.UrlName == myPageName)
.FirstOrDefault();
if
(currentItem !=
null
)
imgMainLogo.ImageUrl = currentItem.GetValue<
string
>(
"ImageIcon"
);
So weird before putting
using Telerik.Sitefinity.Model;