Telerik Reporting: NeedsDataSource

March 15, 2012

This is another for my own benefit :)

NeedsDataSource is a nice way to populate a report, but I always have trouble remembering which Type to cast to for the "object sender" variable

So here's an exampling of Binding to OpenAccess to flatten the data out for the report.

private void crosstab1_NeedDataSource(object sender, EventArgs e) {
    Telerik.Reporting.Processing.Table procReport = (Telerik.Reporting.Processing.Table)sender;
    List<Response> submissions = (from s in context.Responses
    where s.Submission.FormID == new Guid("6F38E890-6FFE-4F50-A8B5-8C5FDADDAF31")
    select s).ToList();
    var formatted = (from s in submissions
                  select new {
                      Submission = s.Submission,
                      SubmissionID = s.SubmissionID,
                      UserID = s.Submission.Userid,
                      SubmissionDate = s.Submission.Submitted,
                      FormID = s.Submission.FormID,
                      QuestionText = s.Question.GetQuestionText("EN", context),
                      AnswerText = s.Answertext,
                      AnswerNumeric = s.Answernumeric
    procReport.DataSource = formatted;

This binds data to the CrossTab item, to bind to the report directly, use


Image Description

Steve McNiven-Scott

Best\Only Blogger on this site. Therefore defacto blogger of the year Award Winner.