RDLC Report in Asp.net MVC - RAJESH GAMI

RDLC Report Created by RAJESH GAMI (Facebook: /Rajesh Gami ... Instagram: rajesh_gami12)


.............................................................................................................
If we need Multiple table in create RDLC report then Create view in SQL server.

==> In SQL server first explore Database then select View and press Right click => New view then select table what we need (e.x  one is Primary.Key second is F.K etc) then select Column check box if we need to all column then select * All Columns otherwise select manualy. then SAVE (Ctrl + S) and give Name of View (e.x Product_view). Now complete work in SQL server Lets start Visual studio.

==> New Project => select Web Application => select MVC 

==> Add NuGet Package Manager so Click on Tools in Visual studio.

==> Tools => NuGet Package Manager => Package Manager Console. then show bottom in visual studio One window box open then our install path paste after PM> 

now take some time then one another paste install package for SQL server 


Now Create New folder in project and give Name RDLC then right click on RLDC folder and Add=>new item => Reporting => Report wizard then give name and then Ok.
 Now create New Connection => select view 

=> Name: e.x  Product-Dataset [Choose your name ]
=> Data Source: e.x RAJ_DashboardDatSet [Select your dataset what we create]
=> Available dataset: e.x Product_view [Select your view dataset] 
then select NEXT 

xsd file create automatically in VS show that... Double click on  RAJ_DashboardDatSet.xsd 
Show our product view. if not show Product_view then drag and Drop from  server explorer.

==> Now add another new file for RDML so Right click on our project then => Add => new item then => select Data then => Select LINQ to SQL classes then give name and OK
now Drag and drop our view (Product_View ) from server explorer 
==> Select server explorer in left side of VS above or Below tool box. if not show Server Explorer then select View and Select Server Explorer .
=> Server Explorer => Data Connection => your database => view => then Drag and Drop your view on rdml side..

==> Create Controller e.x ProductController. show below image



After create controller Paste below code:
-----------------------------------------------------------------------------------------

using Microsoft.Reporting.WinForms;     // must add this nameSpace 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace My_ReportDemo.Controllers
{
    public class ProductController : Controller
    {
        // GET: Product
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ProductPrint()
        {

            RDMLDataContext rdlcdb = new RDMLDataContext();
            LocalReport lr = new LocalReport();
            string mpath = Server.MapPath("~/RDLC/");   // Path // Write your path
            lr.ReportPath = mpath + "Report1.rdlc";   // RDLC file name //So write your Rdlc file name
            lr.EnableExternalImages = true;
            string name = "branch_name"; //For 
            ReportDataSource rd = new ReportDataSource("Product_DataSet", rdlcdb.Product_views.OrderBy(s => s.Product_Name).ToList());

            ReportParameter rp1 = new ReportParameter("parameter", name); //"parameter" is parameter name so give your Parameter name what you have
            lr.SetParameters(new ReportParameter[] { rp1 });
            lr.DataSources.Add(rd);

            string reporttype = "PDF"; //"PDF" write your file ex. Excel,PDF,Doc etc

            // Do not change below Codding Only copy paste
            string mimtype;   
            string encoding;
            string filenameextansion;

            string deviceInfo =

            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>7.8in</PageWidth>" +
            "  <PageHeight>11in</PageHeight>" +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>.5in</MarginLeft>" +
            "  <MarginRight>.5in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            renderedBytes = lr.Render(
                reporttype,
                deviceInfo,
                out mimtype,
                out encoding,
                out filenameextansion,
                out streams,
                out warnings);


            return File(renderedBytes, mimtype);
        }
    }
}

-----------------------------------------------------------------------------------------

Now Add View for Index.

=> Right click on Index => Add view 

select Empty (Without Model) and then Add

paste below code:


Index.cshtml

-------------------------------------------------------------------------------------
@{
    ViewBag.Title = "Index";
}

<h2>Product Data</h2>

<a href="~/Product/ProductPrint">Print</a>

---------------------------------------------------------------------------------------

above code in Product is Controller name and ProductPrint is Action name in Controller



Now select .rdlc file and set your Table data.

show below Image




if Image is not show clearly then right click on image and open new tab



Now run the project and see the result
=================================================
























RAJESH GAMI - Blog

Digital Signature Pad in Angular | RAJESH GAMI

  What is Signature Pad? Signature Pad could be a JavaScript library for drawing fancy signatures. It supports HTML5 canvas and uses variabl...