I am using property class object inside to another property class for reusability as shown below. My problem is that when I click sort on EMP_ID column then error will occur as shown below. but it will working on all the other company direct fields like company_ID, company_Name but for others inherited columns its gives error check the given below code and advise me how to fixed this error thanks.
If I EnableLinqExpressions="false" then its give me error like this
Cannot find column EMP_ID.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.IndexOutOfRangeException: Cannot find column EMP_ID.
If I EnableLinqExpressions="true" then its give me error like this
No property or field 'EMP_ID' exists in type 'Company'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Telerik.Web.UI.ParseException: No property or field 'EMP_ID' exists in type Company'
If I ="true" then its give me error like this
public
class
Employee
{
public
int
Emp_ID {
get
;
set
; }
public
string
Emp_Name {
get
;
set
; }
public
string
Email {
get
;
set
; }
public
bool
? IsActive {
get
;
set
; }
public
bool
? Flag {
get
;
set
; }
public
string
Password {
get
;
set
; }
public
int
Role_ID {
get
;
set
; }
}
public
class
Company
{
public
int
Company_ID {
get
;
set
; }
public
string
Company_Name {
get
;
set
; }
public
string
Phone_No {
get
;
set
; }
private
Employee _modelEmployee;
public
Employee ModelEmployee
{
get
{
if
(_modelEmployee ==
null
)
_modelEmployee =
new
Employee();
return
_modelEmployee;
}
set
{
_modelEmployee = value;
}
}
}
<
telerik:RadGrid
ID
=
"grdSearch"
runat
=
"server"
AllowSorting
=
"True"
AllowPaging
=
"True"
EnableLinqExpressions
=
"false"
AllowCustomPaging
=
"True"
GridLines
=
"None"
Skin
=
"Vista"
ShowGroupPanel
=
"True"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"Company_ID"
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Company_ID"
DataType
=
"System.Int32"
HeaderText
=
"Company_ID"
SortExpression
=
"Company_ID"
UniqueName
=
"Company_ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ModelEmployee.Emp_Name"
DataType
=
"System.String"
HeaderText
=
"Emp_Name"
SortExpression
=
"Emp_Name"
UniqueName
=
"Emp_Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ModelEmployee.Emp_ID"
DataType
=
"System.Int32"
HeaderText
=
"Emp_ID"
SortExpression
=
"Emp_ID"
UniqueName
=
"Emp_ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ModelEmployee.Role_ID"
DataType
=
"System.Int32"
HeaderText
=
"Role_ID"
SortExpression
=
"Role_ID"
UniqueName
=
"Role_ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Edit"
Text
=
"Edit"
UniqueName
=
"column1"
HeaderText
=
"Edit"
>
</
telerik:GridButtonColumn
>
<
telerik:GridButtonColumn
CommandName
=
"View"
Text
=
"View"
UniqueName
=
"column"
HeaderText
=
"View"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowDragToGroup
=
"true"
/>
</
telerik:RadGrid
>