& C# RDLC Report Generation

.aspx.cs file

using System.Configuration;

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

protected void btnGenerateTranscript_Click(object sender, EventArgs e)
String ConString = ConfigurationManager.ConnectionStrings[“RegistrationandExamination”].ConnectionString.ToString();
String SqlString = “sp_TranscriptReportDataGeneration_Old”;
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection(ConString);
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = SqlString;
cmd.Parameters.AddWithValue(“@StudentId”, txtStudentRoll.Text.Trim());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();

ReportDataSource rds = new ReportDataSource(“dsTranscriptAdditionalSheet”, ds.Tables[0]);
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = Server.MapPath(“rptTranscriptAdditionalSheet.rdlc”);

.aspx file
<%@ Register Assembly=”Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
Namespace=”Microsoft.Reporting.WebForms” TagPrefix=”rsweb” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”&gt;
<html xmlns=””&gt;
<head runat=”server”>
<body style=”background-image: url(App_Themes/Images/bg_body_ie.png); background-repeat: repeat-x;”>
<form id=”form1″ runat=”server”>
<div align=”center”>
<fieldset style=”border-color: Black; width: 1px; width: 1000px;”>
<fieldset style=”border-color: Black; width: 1px; width: 600px;”>
<div align=”center”>
<table width=”80%”>
<td align=”right”>
Student Roll
<td width=”150px”>
<asp:TextBox ID=”txtStudentRoll” runat=”server”></asp:TextBox>
<td align=”left”>
<asp:Button ID=”btnGenerateTranscript” runat=”server” Text=”Generate” OnClick=”btnGenerateTranscript_Click” />
<div align=”center”>
<rsweb:ReportViewer ID=”viewer” runat=”server” Font-Names=”Verdana” Font-Size=”8pt”
Height=”750px” InteractiveDeviceInfos=”(Collection)” WaitMessageFont-Names=”Verdana”
WaitMessageFont-Size=”14pt” Width=”800px”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s