public class ben:harrell

May 18, 2010

DevExpress add PivotGridField error

Filed under: .NET, ASP.NET, C#, Uncategorized — benjamin harrell @ 5:24 pm

If you get the “Object must be of type String”  (or Int, etc) while adding a custom field to a Pivot Grid in DevExpress then check to see if you are using CustomGroupIntervals.  If you have a custom GroupInterval you must provide a GroupValue for EVERY case that your values might contain or else you will get this error.

private void grid_CustomGroupInterval(object sender, DevExpress.XtraPivotGrid.PivotCustomGroupIntervalEventArgs e)

{

if ( Convert.ToDecimal(e.Value) < 5)

{

e.GroupValue = “< 5%”;

}

else if (Convert.ToDecimal(e.Value) < 10)

{

e.GroupValue = “< 10%”;

}

else if (Convert.ToDecimal(e.Value) < 15)

{

e.GroupValue = “< 15%”;

}

else if (Convert.ToDecimal(e.Value) <= 20)

{

e.GroupValue = “<= 20%”;

}

else

{

e.GroupValue = “> 20%”;

}

}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: