views:

27

answers:

0

I work on Northwind database

  <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" 
            AutoGenerateColumns="False" DataSourceID="LinqServerModeDataSource1" 
            KeyFieldName="CategoryID">
            <Columns>
                <dxwgv:GridViewCommandColumn VisibleIndex="0">
                    <EditButton Visible="True">
                    </EditButton>
                    <NewButton Visible="True">
                    </NewButton>
                    <DeleteButton Visible="True">
                    </DeleteButton>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="CategoryID" FieldName="CategoryID" 
                    VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="CategoryName" FieldName="CategoryName" 
                    VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Description" FieldName="Description" 
                    VisibleIndex="3">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
        </dxwgv:ASPxGridView>


 <dxdtlnq:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" 
        onselecting="LinqServerModeDataSource1_Selecting" />

C# syntax:

 protected void LinqServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
             NorthwindDataContext db=new NorthwindDataContext();
             var r = db.Categories
                 .Select(p => new { p.CategoryID, p.CategoryName, p.Description });                             
            e.QueryableSource = r;
        }

After run the code show me the error

Key expression is undefined

Why this problem arise.How to solve this problem.