Hello telerik support team,
I have a problem with sorting if I bind an "interface list" to the radgrid. E.g. I have the following code:
When I bind the list to the grid, the binding works, but if I try to sort by the property FirstName or LastName I get the following error:
Thanks in advance.
Thomas Mayer
I have a problem with sorting if I bind an "interface list" to the radgrid. E.g. I have the following code:
AppUser.cs:The AppUser.GetAll() method returns an IList<IAppUser> object.
class AppUser : IAppUser
{
public string Account { get; set; }
public string Password { get; set; }
}
Person.cs
class Person: IPerson
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
IAppUser.cs
public interface IAppUser : IPerson
{
string Account { get; set; }
string Password { get; set; }
}
IPerson.cs
public interface IPerson
{
string FirstName { get; set; }
string LastName { get; set; }
}
grid.aspx:
<asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager>
<telerik:RadGrid ID="dgAppuser" runat="server" AutoGenerateColumns="false" AllowSorting="true">
<MasterTableView AllowNaturalSort="false">
<Columns>
<telerik:GridBoundColumn HeaderText="Account" DataField="Account"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Password" DataField="Password"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="First Name" DataField="FirstName"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Last Name" DataField="LastName"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
grid.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
dgAppuser.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(dgAppuser_NeedDataSource);
}void dgAppuser_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
dgAppuser.DataSource = AppUser.GetAll();
}
When I bind the list to the grid, the binding works, but if I try to sort by the property FirstName or LastName I get the following error:
IndexOutOfRangeException: Column LastName was not found.
If the GetAll() method returns IList<AppUser> instead of IList<IAppUser> the sorting is works.
Is there a solution for this problem or must I add all properties from the base interface also to the derived interface?Thanks in advance.
Thomas Mayer