Click here to Skip to main content
15,444,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i making the subreport for the company. there is 2 parameter in sub report. so how can i set these parameter to sub report. i use subreport inside the Main Report. how this will be achieve by coding ?

Please, help me....

Thanks and Regards...
Updated 22-Jun-12 2:13am
Sandeep Mewara 22-Jun-12 8:15am     CRLF
Once again an open question! :doh: What have you tried? Further, creating subreport at runtime is not too straightforward! Why such a design/need?
[no name] 22-Jun-12 8:26am    
Dear, i make main report with 3 parameter and now use sub report with two paramter. but when i run the page it display like two textboxes because of Parameter field. i have command to run the query in Sub Report.

1 solution

You need to have event handler for sub report
Please refer the below code for the same.
public partial class Pdf : Form

public Pdf()
reportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport2);
private void reportViewer1_suberport2(object sender, SubreportProcessingEventArgs e)

e.DataSources.Add(new ReportDataSource("datasetname",GetDetails(Int32.Parse(e.Parameters[1].Values[0]),e.Parameters[0].Values[0])));

private DataTable GetDetails(int value1,string value2

string conStr = "put your connection string";
SqlConnection sqlCon = new SqlConnection(conStr);
DataSet ds= new DataSet();
SqlCommand objCmd = new SqlCommand();
objCmd.CommandType = CommandType.StoredProcedure;

objCmd.CommandText = "your sp name";
objCmd.Parameters.Add("@parameter1", SqlDbType.Int).Value = value1
objCmd.Parameters.Add("("@parameter2", ", SqlDbType.Int).Value = value2
objCmd.Connection = sqlCon;
SqlDataAdapter objDa = new SqlDataAdapter(objCmd);
objDa.Fill(dsl, "Details");
return ds.Tables[0];

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900