ASPX templates
Version 6.x > ASPX templates > DataRow error View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
tsm612 - 1/4/2012 1:02:44 PM
   
DataRow error
I'm using the Events template from the version 5.5 Corporate Site for my version 6 project, and I'm getting the error "CMS.TreeEngine.TreeNode does not contain a definition for DataRow and no extension method DataRow accepting a first argument of type CMS.TreeEngine.TreeNode could be found." Is there alternative code I can use that will work in 6?

Here's the code behind that's causing the error:
using System;
using System.Web;

using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.UIControls;

using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class EventsTemplate : TemplatePage
{
protected const string mDatyField = "EventDate";

protected void Page_Load(object sender, EventArgs e)
{
if ((CMSContext.CurrentDocument != null) && (CMSContext.CurrentDocument.NodeClassName.ToLower() == "cms.bookingevent"))
{
repEvent.Visible = true;
repEvent.Path = CMSContext.CurrentDocument.NodeAliasPath;

object value = DataHelper.GetDataRowValue(CMSContext.CurrentDocument.DataRow, mDatyField);
if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
{
EventCalendar.TodaysDate = (DateTime)value;
}
}
}
}

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/5/2012 3:27:40 AM
   
RE:DataRow error
Hello,

This issue is caused by the API changes from 5.5 to 6.0. You can find out more in ours CTO blog post. In this case you need to use the GetDataSet method over the tree node to get the data you need.
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(CMSContext.CurrentUser);

CMS.TreeEngine.TreeNode tn = tree.SelectSingleNode(3);

System.Data.DataSet ds = tn.GetDataSet();

Best regards,
Boris Pocatko

User avatar
Certified Developer v7
Certified  Developer v7
tsm612 - 1/13/2012 7:48:57 AM
   
RE:DataRow error
Simple enough, it fixed my issue. Thanks for the help.