Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Used RDLC in my Asp Page but main Report is comming but subreport not comming

C#
<rsweb:ReportViewer ID="ReportViewer1"  runat="server" Font-Names="Verdana" Font-Size="8pt"
                                    InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"
                                    Width="652px">
                                    <LocalReport ReportPath="Student\MyGrade.rdlc">
                                        <DataSources>
                                            <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="MyGrade" />
                                        </DataSources>
                                    </LocalReport>
                                </rsweb:ReportViewer>


C#
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
                              TypeName="MyGradeTableAdapters.usp_mygrading_1TableAdapter" OldValuesParameterFormatString="original_{0}">
                              <SelectParameters>
                                  <asp:SessionParameter  Name="id" SessionField="Stud_id" Type="Int32" />
                              </SelectParameters>
                          </asp:ObjectDataSource>



C#
protected void Page_Load(object sender, EventArgs e)
 {
     try
     {

         if (!IsPostBack)
         {
             this.ReportViewer1.LocalReport.SubreportProcessing += new                 SubreportProcessingEventHandler(prcProcessSubReport);

         }

     }

     catch
     { }
 }



C#
private void prcProcessSubReport(object sender, SubreportProcessingEventArgs e)
   {
       e.DataSources.Clear();

       DataTable dtSubReport = new DataTable();
       ReportDataSource Subreport1;
       try
       {

           SqlConnection thisConnection = new SqlConnection(connection);
           DataSet ds = new DataSet();
           SqlDataAdapter adapter = new SqlDataAdapter();
           thisConnection.Open();
           SqlCommand cmd = new SqlCommand();
           cmd.CommandText = "usp_mygrading_2";
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.Add(new SqlParameter("@id", e.Parameters["id"].Values[0].ToString()));
           cmd.Parameters.Add(new SqlParameter("@exam", e.Parameters["examid"].Values[0].ToString()));

           cmd.Connection = thisConnection;
           adapter = new SqlDataAdapter(cmd);
           adapter.Fill(ds);

           Subreport1 = new ReportDataSource("MyGrade2", dtSubReport);

           e.DataSources.Add(Subreport1);







       }
       catch (Exception ex)
       {

       }
       finally
       {
           dtSubReport = null;
           Subreport1 = null;

       }
   }




I passing Parameter also and i am getting data in coding but when viewing it showing no data
Please Help me..
Posted

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