locked
Cannot determine table from data source RRS feed

  • Question

  • User1037441716 posted
    I'm trying to get simple Dynamic Data filtering to work with my existing project and I'm getting an unhandled exception. 

    I created an Entity Data Model from a specific view in my database, along with a Navigation Property to a parent entity
    Here is the code I added in my Global.asax.cs file for Dynamic Data context registration:

    DefaultModel.RegisterContext(typeof(CIS_DEntities), new ContextConfiguration() { ScaffoldAllTables = true});
    Here is the markup I have in page in which I want Dynamic Data filtering:
    <asp:EntityDataSource ID="GridDataSource" runat="server"  ContextTypeName="DevExpressDynamic.CIS_DEntities" ConnectionString="name=CIS_DEntities" DefaultContainerName="CIS_DEntities"  EnableDelete="true"  EnableInsert="true" EnableUpdate="true"></asp:EntityDataSource>
    
    

    <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
    <asp:DynamicFilterExpression ControlID="FilterRepeater" />
    </asp:QueryExtender>

    ...and just above my data repeater:

    <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
    <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" /><br />
    </ItemTemplate>
    </asp:QueryableFilterRepeater>

    
    


    As soon as I load that page, I get the following unhandled exception:

    Cannot determine table from data source. Use the MetaTable.MapTable method to establish an association between a data source and a MetaTable instance.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: Cannot determine table from data source. Use the MetaTable.MapTable method to establish an association between a data source and a MetaTable instance.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidOperationException: Cannot determine table from data source. Use the MetaTable.MapTable method to establish an association between a data source and a MetaTable instance.]
       System.Web.DynamicData.DynamicDataExtensions.GetMetaTable(IDataSource dataSource, HttpContextBase context) +226793
       System.Web.DynamicData.QueryableFilterRepeater.Page_InitComplete(Object sender, EventArgs e) +73
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.OnInitComplete(EventArgs e) +9088446
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +604
    

    Do you have an idea what I'm doing wrong? :\


    Tuesday, April 28, 2015 3:59 AM

All replies

  • User-330204900 posted

    Hi Sp91 can you post your code behind specifically the Page_Load and Page_Init methods please

    Tuesday, April 28, 2015 4:37 AM
  • User1037441716 posted

    protected void Page_Init(object sender, EventArgs e)
    {

    table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
    GridList.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
    GridDataSource.EntityTypeFilter = table.EntityType.Name;
    string listName = Request.QueryString["field1"];
    GridDataSource.EntitySetName = listName;

    }

    protected void Page_Load(object sender, EventArgs e)
    {
    Title = table.DisplayName;
    GridDataSource.Include = table.ForeignKeyColumnsNames;
    String listName = Request.QueryString["Field1"];
    GridDataSource.EntitySetName = listName;

    // Disable various options if the table is readonly;
    if (table.IsReadOnly)
    {
    GridList.Columns[0].Visible = false;
    InsertHyperLink.Visible = false;
    //GridList.EnablePersistedSelection = false;
    }
    }

    Tuesday, April 28, 2015 5:17 AM
  • User-330204900 posted

    Hi you may have an issue with these setting in the EntityDataSource as the SetMetaTable does this for you so make sure the table field has the correct metastable and you should be good to remove these.

      ContextTypeName="DevExpressDynamic.CIS_DEntities"
      ConnectionString="name=CIS_DEntities"
      DefaultContainerName="CIS_DEntities" 

    Tuesday, April 28, 2015 7:01 AM
  • User1037441716 posted

    if i am removing these parameter.it is showing error that connectionstring,defaultercontainername is required.i am implementing devexpress

    Tuesday, April 28, 2015 8:38 AM
  • User-330204900 posted

    I would post to the DevExpress support if I were you they are very good and will know what you should do here, I only know vanilla EF sorry.

    Tuesday, April 28, 2015 10:08 AM
  • User1037441716 posted

    I have already done that

    Wednesday, April 29, 2015 1:07 AM
  • User-330204900 posted

    have they given any advice on configuring the Entity Data Source with their framework?

    Wednesday, April 29, 2015 4:51 AM