views:

25

answers:

1

What are the requirements for a custom data source to be listed in the 'Data Source' drop-down list when adding a Dataset to a .rdlc report in Report Viewer 2010?

As can been seen from the screen grab, for some reason it is listing potential sources from a variety of referenced assemblies, but I can't see an obvious pattern as to why it is selecting these.

alt text

The 'GeneralDataSet' makes sense as that is a strongly-typed Dataset class, but I'm pretty sure most of the others are not, yet the design dialog still lists them.

I'm looking to roll my own custom data source and would prefer it to be selectable from this list.

A: 

I think it scans your project file looking for methods that return Lists<> and so on.

So something like:

public class Person
{
    public string name { get; set; }
    public int age { get; set; }

public List<Person> GetPeopleList()
{
    return null;
}

public IEnumerable<Person> GetPeopleIEnumerable()
{
    return null;
}

public IQueryable<Person> GetPeopleIQueryable()
{
    return null;
}
}

All three show up, so take your pick. (Code is just thrashed out, ignore bad names/practices :))

But when you use a ReportViewer, you will need to manually set the datasets. Selecting it inside the report from what I have found just basically tells it what data to expect. So add an ObjectDataSource or just set it in the code behind.

Phil