Saturday, 19 May 2012

Report Server in c#


//aspx page

<%@ Page Language="C#" MasterPageFile="~/HOME.master" AutoEventWireup="true" CodeFile="DistrictwiseRainfallReport.aspx.cs" Inherits="DistrictwiseRainfallReport" Title="Untitled Page" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table></table>
<br />
    <asp:Panel ID="Panel1" runat="server" ScrollBars="auto" >
<asp:DropDownList ID="Drpyear" runat="server">
<asp:ListItem>SelectYear</asp:ListItem>
    <asp:ListItem>1980</asp:ListItem>
    <asp:ListItem>1981</asp:ListItem>
    <asp:ListItem>1982</asp:ListItem>
    <asp:ListItem>1983</asp:ListItem>
    <asp:ListItem>1984</asp:ListItem>
    <asp:ListItem>1985</asp:ListItem>
    <asp:ListItem>1986</asp:ListItem>
    <asp:ListItem>1987</asp:ListItem>
    <asp:ListItem>1988</asp:ListItem>
    <asp:ListItem>1989</asp:ListItem>
    <asp:ListItem>1990</asp:ListItem>
    <asp:ListItem>1991</asp:ListItem>
    <asp:ListItem>1992</asp:ListItem>
    <asp:ListItem>1993</asp:ListItem>
    <asp:ListItem>1994</asp:ListItem>
    <asp:ListItem>1995</asp:ListItem>
    <asp:ListItem>1996</asp:ListItem>
    <asp:ListItem>1997</asp:ListItem>
    <asp:ListItem>1998</asp:ListItem>
    <asp:ListItem>1999</asp:ListItem>
    <asp:ListItem>2000</asp:ListItem>
    <asp:ListItem>2001</asp:ListItem>
    <asp:ListItem>2002</asp:ListItem>
    <asp:ListItem>2003</asp:ListItem>
    <asp:ListItem>2004</asp:ListItem>
    <asp:ListItem>2005</asp:ListItem>
    <asp:ListItem>2006</asp:ListItem>
    <asp:ListItem>2007</asp:ListItem>
    <asp:ListItem>2008</asp:ListItem>
    <asp:ListItem>2009</asp:ListItem>
    <asp:ListItem>2010</asp:ListItem>
    <asp:ListItem>2011</asp:ListItem>
</asp:DropDownList>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Clickhere" />

        <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Width="100%">
        </rsweb:ReportViewer>
         </asp:Panel>
</asp:Content>





//code page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;

public partial class DistrictwiseRainfallReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        ReportViewer1.ShowParameterPrompts = false;
        ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
        ReportViewer1.ServerReport.ReportServerUrl = new Uri(System.Configuration.ConfigurationManager.AppSettings["SQL_REPORT_SERVER"]);

        ServerReport objServerReport;
        objServerReport = ReportViewer1.ServerReport;
        objServerReport.ReportPath = System.Configuration.ConfigurationManager.AppSettings["REPORT_FOLDER"] + "DistrictWiseRainfallReport";
//list of parameter define ex:yearwise
        string str2 = Drpyear.SelectedItem.Text;

        ReportParameter objRepoParam_3 = new ReportParameter("YEAR_ID", str2);


        ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { objRepoParam_3 });
        ReportViewer1.ServerReport.Refresh();

    }
}

No comments:

Post a Comment