SSRS REPORT IN ASP.NET
FILE ->NEW WEBSITE->TRACK MICROSOFT REPORT VIEWER
WEBFORM.ASPX
WebForm1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="reportviewer.WebForm1" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="script1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
<asp:Button ID="btn_sub" runat="server" Text="Submit" OnClick="btn_sub_Click" />
</div>
</form>
</body>
</html>
WEBFORM.ASPX.CS
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace reportviewer
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=192.168.1.6;Initial Catalog=Sample_Ecommerce;Integrated Security=true");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_sub_Click(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc");
DataSet ds = GetData("select * from UnitOfMeasurement");
ReportDataSource datasource = new ReportDataSource("DataSet1",ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
private DataSet GetData(string query)
{
string conString = "Data Source=192.168.1.6;Initial Catalog=Sample_Ecommerce;Integrated Security=true";
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
sda.Fill(ds, "UnitOfMeasurement");
return ds;
}
}
}
}
}
}
ADD NEW ITEM->DATASET->RIGHT CLICK->ADD COLUMN->RIGHT CLICK->ADD COLUMN->WRITE IN HEADER FIELD IN DATA COLUMN (SQL TABLE HEADER FILED)
ADD NEW ITEM->REPORT(REPORT1.RDLC)
SET FIELD NAME your table header
Download Source Code:report download