I am stucked at this RDLC for hours now. I want to load two rdlc reports in one report viewer, I want header at the start of a new report, please don't recommend sub reports.
What I have tried:
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Services;
using System.IO;
using System.Data.Sql;
using Microsoft.Reporting.WebForms;
public partial class rdlc : System.Web.UI.Page
{
DataSet DsStockist = new DataSet();
DataTable dtDsStockist = new DataTable();
DataSet DsStockist2 = new DataSet();
DataTable dtDsStockist2 = new DataTable();
string conn = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
BindGrid2();
binddropdown1();
}
}
public void BindGrid()
{
DataSet DsStockist = new DataSet();
DataTable dtDsStockist = new DataTable();
string StrQrry = "";
StrQrry = "SELECT * From task";
string conn = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
SqlDataAdapter adpRpt = new SqlDataAdapter(StrQrry, conn);
adpRpt.Fill(DsStockist, "DsStockist");
adpRpt.Fill(dtDsStockist);
if (DsStockist.Tables[0].Rows.Count > 0)
{
GrdStockist.DataSource = dtDsStockist;
GrdStockist.DataBind();
}
}
public void BindGrid2()
{
DataSet DsStockist2 = new DataSet();
DataTable dtDsStockist2 = new DataTable();
string StrQrry2 = "";
StrQrry2 = "SELECT * From client";
string conn = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
SqlDataAdapter adpRpt2 = new SqlDataAdapter(StrQrry2, conn);
adpRpt2.Fill(DsStockist2, "DsStockist2");
adpRpt2.Fill(dtDsStockist2);
if (DsStockist2.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = dtDsStockist2;
GridView2.DataBind();
}
}
protected void ShowRDLC(object sender, EventArgs e)
{
string conn = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
string StrQrry = "";
StrQrry = "SELECT * From task";
SqlDataAdapter adpRpt = new SqlDataAdapter(StrQrry, conn);
adpRpt.Fill(DsStockist, "DsStockist");
adpRpt.Fill(dtDsStockist);
if (DsStockist.Tables[0].Rows.Count > 0)
{
GrdStockist.DataSource = dtDsStockist;
GrdStockist.DataBind();
}
string StrQrry2 = "";
StrQrry2 = "SELECT * From client";
SqlDataAdapter adpRpt2 = new SqlDataAdapter(StrQrry2, conn);
adpRpt2.Fill(DsStockist2, "DsStockist2");
adpRpt2.Fill(dtDsStockist2);
if (DsStockist2.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = dtDsStockist2;
GridView2.DataBind();
}
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
ReportDataSource datasource = new ReportDataSource("DataSet1", DsStockist.Tables[0]);
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report2.rdlc");
ReportDataSource datasource2 = new ReportDataSource("DataSet2", DsStockist2.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
ReportViewer1.LocalReport.DataSources.Add(datasource2);
}
public override void VerifyRenderingInServerForm(Control control)
{
//required to avoid the runtime error "
//Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server."
}
protected void EcxelBtn_Click(object sender, EventArgs e)
{
ExportGridToExcel();
}
private void ExportGridToExcel()
{
}
public void binddropdown1()
{
}
protected void SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Add_Click(object sender, EventArgs e)
{
}
}
//////////////////////
aspx
///////////////////////////////////////
<%@ Page Title="" Language="C#" MasterPageFile="~/dv.master" AutoEventWireup="true" CodeFile="rdlc.aspx.cs" Inherits="rdlc" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="server">