2009-08-12 18 views
3

ダイナミックdatawebsiteのリストページで集計関数を使用しています。実行すると、私に与えます データバインディング: 'DynamicClass1'には 'EmployeeID'という名前のプロパティが含まれていません。DataBinding: 'DynamicClass1'に '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> 

私は、 表「従業員」持っている「社員、EmployeeNo、EmployeeName、部門...私はLINQのデータソースに選択ContextTypeName、テーブル名、GROUPBYを追加したこと以外は、デフォルトのコードのいずれかを変更していません住所、市、州、国、バージョン "を列として使用します..

これを解決する方法はありますか?

ありがとうございます!

よろしく、 バラ

答えて

2

問題はあなたがグリッドを受け取ることを期待しているデータの種類を作成していないグループ化していることです。 GetDataItem()は特定のタイプのデータを期待していますが、これはLinqDataSourceで設定したものではありません。

GetDateItemは()今、それはない、必要なすべてのアイテム含めるように選択する必要があります。

new(Key, Max(Version) As VersionNo) //EmployeeID needs to be included here 
+0

返信いただきありがとうございます。私はContextTypeName、テーブル名、GROUPBYとLINQのデータソース内の選択を追加した以外、私は –

+0

Tabel従業員は「社員、 EmployeeNo、 EmployeeName、 部門、 住所、 市、 が...デフォルトのコードのいずれかを変更していません州、 国、 バージョン「列など.. –

+0

は=選択の追加 『新しい(キー、VersionNoの、社員としてマックス(版))いいえプロパティまたはフィールド』エラー を与える」 『社員』タイプに存在する 『IGrouping'2』 "私は、GroupBy = "new(EmployeeNo、EmployeeId)"も試みました。それは同じエラーを与える! –

1
new(Key, Max(Version) As VersionNo) is fine. 

従業員...使用を取得するには:Key.Employee

Keyは、group by文で指定されたすべてのプロパティを含む動的クラスです。

他のもの(EmployeeNo、EmployeeName、Department、Address、City、State、Country、Version)には集約ステートメント(Sum、Max、Minなど)が必要です。

関連する問題