I've got a grid that I need to sort by a column that refers to a related entity. I need to figure out the syntax to do this.
Details:
<telerik:GridTemplateColumn UniqueName="AGNUM" DataField="AGNUM" HeaderText="Agent" AllowSorting="True" SortExpression="PAgents.AGNAME"> <EditItemTemplate> <telerik:RadComboBox ID="rcb_Agent_Edit" DataSourceID="Entity_Agents_Active" AppendDataBoundItems="true" DropDownWidth="400px" SelectedValue='<%# Bind("AGNUM") %>' runat="server" DataValueField="AGNUM" DataTextField="AGNAME"> <Items> <telerik:RadComboBoxItem Text="" Value="99999" /> </Items> </telerik:RadComboBox> </EditItemTemplate> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "PAgents.AGNAME") %> <-- Same string works fine here, though. </ItemTemplate></telerik:GridTemplateColumn>The above throws an argument exception: Input string was not in a correct format.Couldn't store in PAgents.AGNAME Column. Expected type is Int32.
The grid is bound to an entity data source (defined below)
The two relevant data sources:
<asp:EntityDataSource ID="Entity_AgLicensing" runat="server" ConnectionString="name=dev_SuretyDBEntities" ContextTypeName="BSGSuretyRewrite.Entities.DataAccess.LinqToEntities.dev_SuretyDBEntities" DefaultContainerName="dev_SuretyDBEntities" EnableFlattening="false" EntitySetName="AgLicense" Include="AgLicenseStatus,PAgents" EnableDelete="true" EnableInsert="true" EnableUpdate="true" Where="it.[PNUMBER]=@PNUMBER && it.[AGNUM] IS NOT NULL" OnInserting="Entity_AgLicensing_Inserting" OnDeleted="Entity_AgLicensing_Deleted" OnUpdating="Entity_AgLicensing_Updating"> <WhereParameters> <asp:ControlParameter ControlID="hfPnumber" Name="PNUMBER" PropertyName="Value" DbType="Int32" /> </WhereParameters></asp:EntityDataSource><asp:EntityDataSource ID="Entity_AgLicensing_Agency" runat="server" ConnectionString="name=dev_SuretyDBEntities" ContextTypeName="BSGSuretyRewrite.Entities.DataAccess.LinqToEntities.dev_SuretyDBEntities" DefaultContainerName="dev_SuretyDBEntities" EnableFlattening="false" EntitySetName="AgLicense" Include="AgLicenseStatus" EnableDelete="true" EnableInsert="true" EnableUpdate="true" Where="it.[PNUMBER]=@PNUMBER && it.[AGNUM] IS NULL" OnInserting="Entity_AgLicensing_Agency_Inserting" OnDeleted="Entity_AgLicensing_Agency_Deleted"> <WhereParameters> <asp:ControlParameter ControlID="hfPnumber" Name="PNUMBER" PropertyName="Value" DbType="Int32" /> </WhereParameters></asp:EntityDataSource>
