Following the help from http://www.telerik.com/help/aspnet-ajax/grdselfreferencinghierarchy.html, I cannot seem to find a FilterExpression that works with my data source. I am using the NeedDataSource event to set the data source like this:
dcConnections is my DataContext, GetMetrics is a stored procedure that returns a list of Metrics. The Metrics have an ID and ParentID, both of which are Guids. ParentID can be null. So, from the example, I tried to set the FilterExpression like this:
This errors out with "No applicable indexer exists in type 'Metric'", which makes sense, since I need to use the it.ParentID format to get to the column in the Metric normally, so I change it to this:
That errors with "Operator '==' incompatible with operand types 'Guid?' and 'Object'".
So now, I can't figure out how to compare the values of a Guid? in a FilterExpression. Normally, using == null would work for Nullable Guids. Any suggestions?
dcConnections dc =
new
dcConnections();
g.DataSource = dc.GetMetrics();
dcConnections is my DataContext, GetMetrics is a stored procedure that returns a list of Metrics. The Metrics have an ID and ParentID, both of which are Guids. ParentID can be null. So, from the example, I tried to set the FilterExpression like this:
if
(Assembly.GetAssembly(
typeof
(ScriptManager)).FullName.IndexOf(
"3.5"
) != -1 || Assembly.GetAssembly(
typeof
(ScriptManager)).FullName.IndexOf(
"4.0"
) != 1)
{
g.MasterTableView.FilterExpression = @
"it["
"ParentID"
"] == null"
;
}
else
{
g.MasterTableView.FilterExpression =
"ParentID IS NULL"
;
}
This errors out with "No applicable indexer exists in type 'Metric'", which makes sense, since I need to use the it.ParentID format to get to the column in the Metric normally, so I change it to this:
g.MasterTableView.FilterExpression = @
"it.ParentID == null"
;
That errors with "Operator '==' incompatible with operand types 'Guid?' and 'Object'".
So now, I can't figure out how to compare the values of a Guid? in a FilterExpression. Normally, using == null would work for Nullable Guids. Any suggestions?