DataBinding: "DynamicClass1" does not contain a property named "EmployeeID"

I used the aggregate function in the list page of a dynamic datawebsite. When it is executed, it gives me DataBinding: "DynamicClass1" does not contain a property named "EmployeeID".

  <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"
                AllowPaging="True" AllowSorting="True" CssClass="gridview">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID="EditHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Edit, GetDataItem()) %>'
                            Text="Edit" />&nbsp;<asp:LinkButton ID="DeleteLinkButton" runat="server" CommandName="Delete"
                                CausesValidation="false" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />&nbsp;<asp:HyperLink ID="DetailsHyperLink" runat="server"
                                NavigateUrl='<%# table.GetActionPath(PageAction.Details, GetDataItem()) %>'
                                Text="Details" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <PagerStyle CssClass="footer"/>        
                <PagerTemplate>
                    <asp:GridViewPager runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    There are currently no items in this table.
                </EmptyDataTemplate>
            </asp:GridView>

            <asp:LinqDataSource ID="GridDataSource" runat="server" 
            ContextTypeName="DataClassesDataContext" 
              TableName="Employees" 
              GroupBy="EmployeeNo"
              Select="new(Key, 
                Max(Version) As VersionNo)"
            EnableDelete="true">
                <WhereParameters>
                    <asp:DynamicControlParameter ControlID="FilterRepeater" />
                </WhereParameters>
            </asp:LinqDataSource>

I did not change any default code, except that I added ContextTypeName, TableName, GroupBy and select in Linq Data source ... The Employees table has the columns EmployeeID, EmployeeNo, EmployeeName, Department, Address, City, State, Country, Version. "

Any idea how to solve this?

Thanks in advance!

Regards, Bala

+3
source share
2

, , , . GetDataItem() , LinqDataSource.

, GetDateItem(), :

new(Key, Max(Version) As VersionNo) //EmployeeID needs to be included here
+2
new(Key, Max(Version) As VersionNo) is fine.

... : Key.Employee

- , , .

- ( EmployeeNo, EmployeeName, Department, Address, City, State, Country, Version) (, Sum, Max, Min).

+1

Source: https://habr.com/ru/post/1714996/


All Articles