ASPX templates
Version 4.x > ASPX templates > How to Bind Latest News fields View modes: 
User avatar
Member
Member
srizzetto-microgate - 3/23/2009 12:59:02 PM
   
How to Bind Latest News fields
Do you have a sample how to bind on my homepage the title, summary and link to a labels and ha hyperlink controls of the NEWEST (top 1 releaseDate Desc) news (document of type news) ?

I'm in doubt if I have to query directly the DB or I could use some API to achieve the same result.

Thanks
Sandro

User avatar
Member
Member
dukebaby - 3/23/2009 4:01:07 PM
   
RE:How to Bind Latest News fields
Assuming your news documents are stored in the path /News/% this should work:

<cms:CMSRepeater runat="server" ID="cmsrepNews" Path="/News/%" ClassNames="CMS.News" SelectTopN="1" OrderBy="NewsReleaseDate DESC" TransformationName="CMS.News.NewsWithSummary" />

User avatar
Member
Member
srizzetto-microgate - 3/24/2009 3:08:37 AM
   
RE:How to Bind Latest News fields
That's great, I will sure try it. Thank you

But for my knowledge... Does it exists a method driven by code-behind ? I had to hide some panel if no news exists

eg. (pseudo-code)

//retrieve Last news
if (! exists)
pnlNews.Visible = false;
else
lblTitle.Text = news.Title // or row["Title"].ToString();

thx

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/26/2009 10:14:31 AM
   
RE:How to Bind Latest News fields
Hello,

You can use SelectNodes function. Please see http://www.kentico.com/docs/devguide/selecting_nodes.htm for more details.

Best Regards,

Martin Dobsicek