Display RDLC report column wise using Matrix Report in ASP.Net

Last Reply 15 days ago By pandeyism

Posted 15 days ago

how to display 1 to 10 numbers in column wise in rdlc report

Ex :

1  2  3  4  5  6  7  8  9  10

 

You are viewing reply posted by: pandeyism 15 days ago.
Posted 15 days ago

Hi Faizal,

Using the below article i have created the example.

How to create RDLC report step by step in ASP.Net using C# and VB.Net

According to your requirement you have to use matrix Report.

For this you need to add Matrix component from Toolbox ReportItems inside your report wizard.

Adding Matrix In Rdlc Report

For more details on adding a Matrix refer below link.

https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms157334%28v=sql.100%29

Database

For this sample I have used of NorthWind database Employee Table that you can download using the link given below.

Download Northwind Database

HTML

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600">
</rsweb:ReportViewer>

Namespaces

using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;

C#

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ReportViewer1.ProcessingMode = ProcessingMode.Local;
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report2.rdlc");
        Employees dsCustomers = GetData("select * from Employees");
        ReportDataSource datasource = new ReportDataSource("Employees", dsCustomers.Tables[0]);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);
    }
}

private Employees GetData(string query)
{
    string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    SqlCommand cmd = new SqlCommand(query);
    using (SqlConnection con = new SqlConnection(conString))
    {
        using (SqlDataAdapter sda = new SqlDataAdapter())
        {
            cmd.Connection = con;

            sda.SelectCommand = cmd;
            using (Employees dsEmployees = new Employees())
            {
                sda.Fill(dsEmployees, "DataTable1");
                return dsEmployees;
            }
        }
    }
}

Screenshot