Hello,
I have a problem acessing a Table's DataObject that lies in the Detail Section.
The Detail Section's Datasource is set to a list of Questions and I want to display
a List with the possible answers of each Question. So I use the ItemDataBind of
the Detail Section to set each Processing.Table Datasource:
carta.Items["detail"].ItemDataBinding += detail_ItemDataBind;
((List)carta.Items["detail"].Items["ListAnswers"]).ItemDataBinding += ListAnswers_ItemDataBind;
private void detail_ItemDataBind(object sender, EventArgs e)
{
var detail = sender as Telerik.Reporting.Processing.DetailSection;
var processingTable = detail.ChildElements.Find("ListAnswers", true)[0] as Telerik.Reporting.Processing.Table;
Question question = detail.DataObject.RawData as Question;
processingTable.DataSource = question.AnswersList;
}
this works fine, but if I want to access each Answer object within the ListAnswers ReportItem I get a ClassCast exception, because
the List.DataObject is set to the same object as Detail.DataObject, even though I set a different Datasource to them:
private void ListAnswers_ItemDataBind(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Table tableProc = (Telerik.Reporting.Processing.Table)sender;
// class cast error here, RawData is a Question instead of Answer, but tableProc.Datasource is a list of Answer
Answer answer = (Answer) tableProc.DataObject.RawData;
}
What am I missing ?
I have a problem acessing a Table's DataObject that lies in the Detail Section.
The Detail Section's Datasource is set to a list of Questions and I want to display
a List with the possible answers of each Question. So I use the ItemDataBind of
the Detail Section to set each Processing.Table Datasource:
carta.Items["detail"].ItemDataBinding += detail_ItemDataBind;
((List)carta.Items["detail"].Items["ListAnswers"]).ItemDataBinding += ListAnswers_ItemDataBind;
private void detail_ItemDataBind(object sender, EventArgs e)
{
var detail = sender as Telerik.Reporting.Processing.DetailSection;
var processingTable = detail.ChildElements.Find("ListAnswers", true)[0] as Telerik.Reporting.Processing.Table;
Question question = detail.DataObject.RawData as Question;
processingTable.DataSource = question.AnswersList;
}
this works fine, but if I want to access each Answer object within the ListAnswers ReportItem I get a ClassCast exception, because
the List.DataObject is set to the same object as Detail.DataObject, even though I set a different Datasource to them:
private void ListAnswers_ItemDataBind(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Table tableProc = (Telerik.Reporting.Processing.Table)sender;
// class cast error here, RawData is a Question instead of Answer, but tableProc.Datasource is a list of Answer
Answer answer = (Answer) tableProc.DataObject.RawData;
}
What am I missing ?