Dynamic Data: “Instance property ‘it’ is not defined for type” error

In Dynamic Data site, filtering the table and then re-ordering it results in error:

Instance property ‘it’ is not defined for type

 
There’s a workaround to solve this problem!

Open \DynamicData\PageTemplates\List.aspx and add an OnSelecting event for the EntityDataSource:

<asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true" 
      OnSelecting="GridDataSource_Selecting" />

 
Now open the code behind and paste the following snippet:

protected void GridDataSource_Selecting(object sender, EntityDataSourceSelectingEventArgs e)
{
    string s = e.SelectArguments.SortExpression;
    if (s.StartsWith("it."))
        e.SelectArguments.SortExpression = s.Substring(3);
}

 

Advertisements

5 thoughts on “Dynamic Data: “Instance property ‘it’ is not defined for type” error

  1. That only works if you are using a control that only sorts by a single column at a time. A better solution is to use:

    e.SelectArguments.SortExpression = e.SelectArguments.SortExpression.Replace(“it.”, “”);

    to remove the prefix. That way, it works when multiple columns are sorted too.

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