How to create RDLC report in asp.netStep 1: Create DatabaseStep 2: Create Asp.net Web Application
Step 3: Add Microsoft Report Viewer in Asp.net Web Application
<%@ Page Language="C#" MasterPageFile=".Master" AutoEventWireup="true" CodeBehind=".aspx.cs" Inherits=".WebForm4" Title="Untitled Page" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="#333333"
Font-Size="8pt" Height="315px"
ShowCredentialPrompts="False" ShowDocumentMapButton="False"
ShowFindControls="False" ShowPageNavigationControls="False"
ShowParameterPrompts="False" ShowPromptAreaButton="False"
ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True"
Width="710px">
<LocalReport ReportPath="Customer\Order_History.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="DataSet2_order_history" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="Online Gas Agency System.DataSet2TableAdapters."
onselecting="ObjectDataSource1_Selecting">
</asp:ObjectDataSource>
</asp:Content>
Step 4: Add Report .rdlc crystal report
Step 5: Add Data Set
Step 6: Add table from toolbox in report
Step 7: Design Report as per requirement
Step 8: Code Behind
SqlConnection con =newSqlConnection(@"DataSource=.\sqlexpress;Initial Catalog=DB;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter("Select col1,col2,... from table_name", con);
DataTable dt = new DataTable();
da.Fill(dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet2_order_history";
rds.Value = dt;
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
nice...
ReplyDeleteit helps me lot..