Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > UniView and GroupedDataSource View modes: 
User avatar
Member
Member
matt.barry-stockhouse - 9/24/2012 2:06:48 PM
   
UniView and GroupedDataSource
Hello:

I'm using the UniView to display forum posts within a thread. The code looks something like this:


DataSet ds = ForumPostInfoProvider.SelectForumPosts(ForumID, "/%", "PostIDPath Like '" + ForumPostInfoProvider.GetPath(null, ThreadID) + "%'", ThreadOrderBy, MaxRelativeLevel, onlyPublish, -1, null, currentOffset, maxRecords, ref totalRecords);

if (!DataHelper.DataSourceIsEmpty(ds))
{
GroupedDataSource gpd = new GroupedDataSource(ds, "PostParentID", "PostLevel");
listForums.RelationColumnID = "PostId";
listForums.DataSource = gpd;
listForums.DataBind();
}



The problem is that the top level post has a PostParentID of NULL. So when I data bind I get an "Object cannot be cast from DBNull to other types" exception.

Is there any way to tell UniView that the top-level post in my hierachy is going to have a NULL parent ID? Or do I have to loop through my dataset and change the parent ID to something like -1?

Thanks in advance!

User avatar
Member
Member
matt.barry-stockhouse - 9/24/2012 2:11:35 PM
   
RE:UniView and GroupedDataSource
FYI, I'm basing my code on this example, which uses TreeHelper.SelectNodes instead of ForumPostInfoProvider.SelectForumPosts, but same idea:

http://devnet.kentico.com/docs/6_0/controls/index.html?uniview_getting_started.htm

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/25/2012 4:48:33 AM
   
RE:UniView and GroupedDataSource
Hi,

and what are you using in the UniView transformation?

I mean are not you displaying the null field using:

<ItemTemplate>

<%# HTMLHelper.HTMLEncode( Convert.ToString(Eval("YourNullField"))) %>

</ItemTemplate>


Best regards,
Ivana Tomanickova

User avatar
Member
Member
matt.barry-stockhouse - 9/25/2012 11:11:49 AM
   
RE:UniView and GroupedDataSource
Nope, I'm not actually displaying the null field (PostParentId). The UniView uses it to establish the relationship between items n the hierarchy. Obviously the top level node in the tree is going to have a null parent, but this causes the UniView to throw an exception.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/27/2012 8:40:33 AM
   
RE:UniView and GroupedDataSource
Hi,

finally, this seems to be a bug as uniview and grouped data source are not cooperating correctly. We will try to fix it in the hotifx. I am sorry for inconvenience.

Best regards,
Ivana Tomanickova