views:

293

answers:

2

Does the asp.net ReportViewer control work with LinqDataSource? If so are there any examples out there?

Why don't Linq to Sql generated entity classes show up in the Website Data Sources pane, when editing a report?

A: 

Read this article :http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx

Check this one also :http://www.youtube.com/watch?v=IVPxn9_idS4

Hope you will get any idea out from this..

Ramesh
+1  A: 

It appears the Website Data Sources pane will only show you all classes that have public methods that return IEnumerable, but it won't show properties, even if they also return IEnumerable. For example, if you have this class:

public class Name

{
    public Name(string firstName, string lastName)
    {
        FirstName = firstName;
        LastName = lastName;
    }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
public class Class1
{
    public IEnumerable<Name> Names { get; set; }

    public IEnumerable<Name> GetNamesList()
    {
        List<Name> list = new List<Name>();
        list.Add(new Name("Al", "Alverson"));
        list.Add(new Name("Bill", "Billerson"));
        return list;
    }
}

Then the only option that will appear in the Website Data Sources pane is "GetNamesList" with the properties FirstName and LastName. Since your Linq-to-SQL generated classes have properties that are IQueryable, but not methods, you might want to add partial classes that have methods to expose these collections. So if you have a Products property, create a partial class with a signature of:

public IEnumerable GetAllProducts();

But I'm not sure that you can make the ReportViewer work with an existing LinqDataSource control. Instead, it basically does the same thing as the LinqDataSource: instantiates a class and calls the method you specify to get data.

Helpful Links: http://msdn.microsoft.com/en-us/library/ms251692(VS.80).aspx http://forums.asp.net/p/1430385/3667394.aspx

lividsquirrel