L
Lammert
Good afternoon,
I have a very strange problem. When I execute the code below the
program throws an InvalidCastException. When I debug the code I see
e.Item.DataItem is an object from the type OrganisatieOnderdeel. When
you read the additional you can see the types are the same. How can I
solve this problem?
Kinds regards,
Lammert
Code:
protected void fvwContact_ItemDataBound(object sender,
DataListItemEventArgs e)
{
ObjectDataSource ods = new ObjectDataSource();
ods.TypeName = "BusinessLogicLayer.FunctieVervulling";
ods.SelectMethod = "GetFunctieVervullingenById";
// An exception of type 'System.InvalidCastException' occurred in this
this line:
OrganisatieOnderdeel oo =
(OrganisatieOnderdeel)e.Item.DataItem;
ods.SelectParameters.Add("id", TypeCode.Int32,
oo.Id.ToString());
DataList ds = (DataList)e.Item.FindControl("dlPersonen");
ds.DataSource = ods;
ds.DataBind();
}
Message:
An exception of type 'System.InvalidCastException' occurred in
WebApp.DLL but was not handled in user code
Additional information: Unable to cast object of type
'BusinessLogicLayer.OrganisatieOnderdeel' to type
'BusinessLogicLayer.OrganisatieOnderdeel'.
I have a very strange problem. When I execute the code below the
program throws an InvalidCastException. When I debug the code I see
e.Item.DataItem is an object from the type OrganisatieOnderdeel. When
you read the additional you can see the types are the same. How can I
solve this problem?
Kinds regards,
Lammert
Code:
protected void fvwContact_ItemDataBound(object sender,
DataListItemEventArgs e)
{
ObjectDataSource ods = new ObjectDataSource();
ods.TypeName = "BusinessLogicLayer.FunctieVervulling";
ods.SelectMethod = "GetFunctieVervullingenById";
// An exception of type 'System.InvalidCastException' occurred in this
this line:
OrganisatieOnderdeel oo =
(OrganisatieOnderdeel)e.Item.DataItem;
ods.SelectParameters.Add("id", TypeCode.Int32,
oo.Id.ToString());
DataList ds = (DataList)e.Item.FindControl("dlPersonen");
ds.DataSource = ods;
ds.DataBind();
}
Message:
An exception of type 'System.InvalidCastException' occurred in
WebApp.DLL but was not handled in user code
Additional information: Unable to cast object of type
'BusinessLogicLayer.OrganisatieOnderdeel' to type
'BusinessLogicLayer.OrganisatieOnderdeel'.