Sunday, January 15, 2017

Microsoft RDLC creation by C# programatically. Reporting servicescreate & View Simple RDLC Report in ASP.NET (C#)

Microsoft RDLC creation by C# programatically.Reporting services cretion.


create & View Simple RDLC Report in ASP.NET (C#)

 C# Code.

<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" /><br />
        <rsweb:ReportViewer ID="ReportViewer1" runat="server">
           
        </rsweb:ReportViewer>
 

Aspx code.

protected void Button2_Click(object sender, EventArgs e)
        {
            DataTable dtt = new DataTable();
            dtt.Columns.Add("Serial",typeof(string));
            dtt.Columns.Add("Name", typeof(string));
            dtt.Columns.Add("Dept", typeof(string));
            dtt.Columns.Add("Salary", typeof(string));
            dtt.Rows.Add("1","ShayamJi",".Net","20000");
            dtt.Rows.Add("2", "Ashish Ji", "Sharepoint", "30000");
            dtt.Rows.Add("3", "Trupthi ji", "Java", "21000");


            ReportDataSource dsrpt = new ReportDataSource("market", dtt);

            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(dsrpt);
            ReportViewer1.LocalReport.ReportPath=(Server.MapPath("Report1.rdlc"));
            ReportViewer1.LocalReport.Refresh();
            //this.ReportViewer1.ReportRefresh();
            //ReportViewer1.LocalReport.ReportEmbeddedResource
        }

 Steps:

1. Create a simple asp.net empty project.

2. In default.aspx insert ReportViewer form Toolbox=>Reporing.

3. Add new item DataSet in project.

4. Add table in DataSet table name and code name should be same.  

5. Add Report without wizard in project in  Solution Explorer.

6. In Report Data window add new and dataset.

7. In dataset Wizard give name and select the DataSetName1.xsd .

8. Add table in Rdlc and drag drop the column.


No comments:

Post a Comment