i have a rdlc report that is bound to following class:
public class Product
{
DataContext context;
public Product()
{
context = new DataContext();
}
public List<Product> GetBoughtItemsForUser(string userName)
{
//linq query to collect data
return query.ToList();
}
public string Name {get;set;}
public int Quantity {get;set;}
}
in my rdlc i've set the report dataset to GetBoughtItemsForUser. now i want to pass the userName value which is actually the Page.User.Identity.Name so how should i do this?
var p = new Product();
//fill class properties with data
ReportParameter[] params = new ReportParameter[2];
params[0] = new ReportParameter("Name ", p.Name , false);
params[1] = new ReportParameter("Quantity ", p.Quantity , false);
this.ReportViewer1.ServerReport.SetParameters(params);
this.ReportViewer1.ServerReport.Refresh();