This is a migrated thread and some comments may be shown as answers.

Error-Not all code paths return a value

3 Answers 92 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Radhika
Top achievements
Rank 1
Radhika asked on 20 Jun 2012, 11:50 AM
Hello

I am working with Telerik reports in Microsoft Visual Studio 2010. Using the code in a Telerik Reporting Tutorial, I am trying to use a C# code the designer code to populate and assign a data source. Following is my code:

namespace ClassLibrary3
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
    using System.Collections.Generic;

    /// <summary>
    /// Summary description for Report5.
    /// </summary>
   

    public partial class Report5 : Telerik.Reporting.Report
    {
      public Product ProductList()  
//The error here is' Not all code paths return a value'
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
            List<Product> products = new List<Product>();
            products.Add(new Product("bicycle"));
            products.Add(new Product("helmet"));
            products.Add(new Product("shoes"));
// Assign the generic list as the report DataSource
            this.DataSource = products;
         

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
    }
     public class Product
{
private string _name;
public Product(string name)
{
_name = name;
}
public string Name
{
get { return _name; }
    set { _name = value; }
}
}
}

Can someone please help me out? How do I get rid of this error message and preview the report?

Thanks,

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 20 Jun 2012, 01:15 PM
Hi Radhika,

Find attached a working report with your code and let us know if further help is needed.

Kind regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Radhika
Top achievements
Rank 1
answered on 21 Jun 2012, 05:29 AM
Thanks, Steve! It's working now.
Could you please tell me what was wrong with the previous code? Also, I just used the .cs code you gave me. Do I need to integrate the .Designer.cs code somewhere as well?

Regards
Radhika
0
Steve
Telerik team
answered on 21 Jun 2012, 10:08 AM
Hi Radhika,

I've used your data source for the sample report, so you can compare the differences to find the culprit. Just paste directly the 3 files to your report class library and after a rebuild of the project, it would be recognized from the VS designer as a report and you would be able to work with it via the report designer as well.

Greetings,
Steve
the Telerik team

FREE WEBINAR ON THE NEW REPORT DESIGNER! Join us on Friday, June 29 at 10:00 AM for a comprehensive demo of the official version of the standalone Report Designer and find out how easy it is to empower your users with creating, editing and sharing ad-hoc reports. The webinar will go through a real-world scenario of creating reports, embedding them in your application(s), and distributing them within your organization. We will also cover the newly added support for sub-reports, navigation actions (such as drill-down and drill-through), and report sources. Register here and bring your questions with you. We’ll try to address them during the webinar! You may even win a Telerik Ultimate Collection license! Register today >>

Tags
General Discussions
Asked by
Radhika
Top achievements
Rank 1
Answers by
Steve
Telerik team
Radhika
Top achievements
Rank 1
Share this question
or