Tuesday 6 October 2015

SSRS in Asp.net

Step 1: Create Dataset

SSRS1.gif

Step 2: Create and Bind .rdlc file with Dataset.

SSRS2.gif

Step 3: Add ReportViewer and call your .rdlc file.

SSRS3.gif

So your .aspx file looks like this.
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <rsweb:reportviewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
    Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="90%">
        <LocalReport ReportPath="Reports\bal.rdlc">
        </LocalReport>
    </rsweb:reportviewer>

So your .cs file looks like this.

using System.Drawing;
using Microsoft.Reporting.WebForms;
 private void BindReportViewer()
        {

            dsbal m = new dsbal();
            da = new SqlDataAdapter("select * from vwShowBalance", con);
            da.Fill(m, m.Tables[0].TableName);
            ReportDataSource rds = new ReportDataSource("DataSet1", m.Tables[0]);

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.DataSources.Add(rds);
            this.ReportViewer1.LocalReport.Refresh();
            
        }