Archive for October 2006
Loading *.rdlc stored outside the assembly
I am back with the ReportViewer control shipped in .NET 2.0
What is the problem again? well it not much I just want to share about how I can load the *.rdlc file stored outside the Assembly.
Okay, let say my application have the following structure:

By store the report separate from the BillionDollarApp.exe (not embed *.rdlc as an assembly resource) it allow me to make change to the report without having to recompile my app.
To load the report file:
string stRDLCFileName = "Report1.rdlc"; this.reportViewer1.LocalReport.ReportPath = "Reports\\" + stRDLCFileName; this.reportViewer1.RefreshReport();
Until then it all for now ;)
Using collection object as report datasource
Chorn Chan Reasey, my very first daughter.
Well I am not gonna talk much about her now since I am still at my early stage as a father :)
Today topic is:
“How to pass Generic collection to Report.rdlc DataSource”
Well if you follow the walkthrough in MSDN everything seem to work perfect. However I ran into a situation where I define my object as bellow:
public class Person{
private string _firstname;
private string _lastname;
public string FirstName{
get{ return _firstname;}
set{ _firstname = value;}
}
public string LastName{
get{ return _lastname;}
set{ _lastname = value;}
}
public Person(string fname, string lname){
_firstname = fname;
_lastname = lname;
}
}
okay, nothing wrong it just a normal object definition right?
Then I go
public class PersonList{
List m_Persons = new List();
public List Persons{
get{ return m_Persons;}
}
public PersonList(){
m_Persons.Add(new Person("Chorn", "Sokun"));
m_Persons.Add(new Person("Yim", "Seiha"));
m_Persons.Add(new Person("Chorn", "Chan Reasey"));
}
}
again it simple once.
Now when I tried to pass PersonList to Report.rdlc I hope that the following statement will do the job:
PersonList list = PersonList(); /* this is not gonna work - how I stuck. */ personBindingSource.DataSource = list; /* this is how I should assign it */ DataSource = list.Persons;
