This is a migrated thread and some comments may be shown as answers.

Field PG_C_ENTITY_ID not found in the source table. Please check the expression syntax.

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yashwant
Top achievements
Rank 1
Yashwant asked on 15 Nov 2016, 07:35 AM

Hi I am new to telerik and trying to group grid based on PG_C_ENTITY_ID. though this field is available in data source I am getting the error :Field PG_C_ENTITY_ID not found in the source table. Please check the expression syntax.

PFA the datasource image. please guide on the same.

 

on ascx page :

 

 <telerik:RadGrid RenderMode="Lightweight" ID="PricingGroupGrid" runat="server" PageSize="20"
                                    AllowMultiRowSelection="True" AllowPaging="True" ShowGroupPanel="True"
                                    AutoGenerateColumns="False" GridLines="none" OnNeedDataSource="PricingGroupGrid_NeedDataSource" 
                                    OnItemCommand="PricingGroupGrid_ItemCommand">
                                    <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
                                    <MasterTableView Width="100%">
                                        <GroupByExpressions>
                                            <telerik:GridGroupByExpression>
                                                <SelectFields>
                                                    <telerik:GridGroupByField FieldName="PG_C_ENTITY_ID"></telerik:GridGroupByField>
                                                </SelectFields>
                                                <GroupByFields>
                                                    <telerik:GridGroupByField FieldName="PG_C_ENTITY_ID"></telerik:GridGroupByField>
                                                </GroupByFields>
                                            </telerik:GridGroupByExpression>
                                        </GroupByExpressions>
                                        <Columns>
                                            <telerik:GridEditCommandColumn HeaderText="Edit" ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderStyle-Font-Bold="true">
                                                <HeaderStyle Width="80px"></HeaderStyle>
                                                <ItemStyle CssClass="MyImageButton"></ItemStyle>
                                            </telerik:GridEditCommandColumn>
                                            <telerik:GridBoundColumn SortExpression="PricingTyp" HeaderText="Type" UniqueName="PricingTyp" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="PricingTyp">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn SortExpression="RatePlanId" HeaderText="Rate Plan Id" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="RatePlanId">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn SortExpression="DisplayStartDate" HeaderText="Start Date" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="DisplayStartDate">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn SortExpression="DisplayEndDate" HeaderText="End Date" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="DisplayEndDate">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn SortExpression="DisplayRate1" HeaderText="Rate" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="DisplayRate1">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn SortExpression="RateClass" UniqueName="RateClass" HeaderText="Rate Class" HeaderButtonType="TextButton" HeaderStyle-Font-Bold="true"
                                                DataField="RateClass">
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings ReorderColumnsOnClient="false" AllowDragToGroup="false" AllowColumnsReorder="false">
                                        <Selecting AllowRowSelect="True"></Selecting>
                                        <Resizing AllowRowResize="false" AllowColumnResize="false" EnableRealTimeResize="false"
                                            ResizeGridOnColumnResize="False"></Resizing>
                                    </ClientSettings>
                                    <GroupingSettings ShowUnGroupButton="false"></GroupingSettings>
                                </telerik:RadGrid>

 

on ascx.cs page:

 

 int pgId = 0;
            IEnumerable<LGCPricingGroup> lgcPricingGroup = new Prospects().GetPricingGroups(dealsheetId);
            List<LGCPricingBlock> lstPricingBlocks = new List<LGCPricingBlock>();
            //IEnumerable<LGCPricingBlock> lgcPricingBlocks = Enumerable.Empty<LGCPricingBlock>();
            foreach (var lgcPgGroup in lgcPricingGroup)
            {
                pgId = lgcPgGroup.Id;
                List<LGCPricingBlock> lstPricingBlock = new List<LGCPricingBlock>();
                IEnumerable<LGCPricingBlock> lgcPricingBlocks = new Prospects().GetPricingBlocksByPricingGroup(pgId);
                lstPricingBlock = lgcPricingBlocks.ToList();
                foreach (var item in lstPricingBlock)
           {
                    //GridGroupByExpression expression = new GridGroupByExpression();
                    //GridGroupByField gridGroupByField = new GridGroupByField();
                    //gridGroupByField = new GridGroupByField();

                    //gridGroupByField.FieldName = "item.PG_C_ENTITY_ID";
                    //gridGroupByField.FieldAlias = "item.PG_C_ENTITY_ID";
                    //gridGroupByField.HeaderText = "Pricing Group" + lgcPgGroup.PricingGroupSeq;
                    //expression.SelectFields.Add(gridGroupByField);
                    //RadGrid1.MasterTableView.GroupByExpressions.Add(expression);
                    lstPricingBlocks.Add(item);
           }
            }
            PricingGroupGrid.DataSource = lstPricingBlocks;
            PricingGroupGrid.DataBind();

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 18 Nov 2016, 06:18 AM
Hi Yashwant,

Please make sure that you are not using the DataBind() method to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:

Declarative DataSource (DataSourceID property)
Programmatic Data Binding (NeedDataSource event, + DetailTableDataBind for hierarchy). You should set the DataSource property ONLY within these event handler.

That should resolve the issue.

Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Yashwant
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or