2009-08-27 12 views
13

नहीं होगा मेरे पास एक एएसपीएक्स पेज पर क्रिस्टल रिपोर्ट व्यूअर कंट्रोल है, जिसमें अंतर्निहित पेजिंग होना चाहिए।क्रिस्टल रिपोर्ट व्यूअर पिछले पृष्ठ 2

जब मैं "अगले पृष्ठ" बटन पहली बार क्लिक करें, मैं पेज 2 के पेज 1 से ले जाते हैं, लेकिन हर दूसरे समय मैं "अगले पृष्ठ" पृष्ठ 2.

+0

पोस्ट अपने ReportViewer कोड-पीछे उपयोगी मदद पाने के लिए! –

उत्तर

22

समस्या हो सकती है करने के लिए रिपोर्ट पुनः लोड क्लिक करें Page_Load घटना के दौरान क्रिस्टल रिपोर्ट व्यूअर नियंत्रण ReportSource सेट करने से स्टेम। यह पेजिंग जानकारी को प्रत्येक पृष्ठ लोड के साथ ओवर-लिखित करने का कारण बनता है, इसलिए "वर्तमान पृष्ठ" को 2 पर फिर से सेट किया जाना चाहिए जब यह 2 पर होना चाहिए।

एक आसान समाधान के रूप में, आप सेट कोड को स्थानांतरित कर सकते हैं ReportSourcePage_Init

+0

आपको बहुत बहुत धन्यवाद! – Slovo

+0

पेज_इनिट पर जाने से समस्या हल हो जाती है, लेकिन अब मुझे इसके रिपोर्ट स्रोत को बंद करने में कोई समस्या है। मैं इन विधियों को रिपोर्ट को कॉल करना चाहता हूं। बंद करें(); रिपोर्ट। उद्देश्य(); लेकिन मैं उन्हें पेज_इनिट के दौरान कॉल नहीं कर सकता। कनेक्शन बंद किए बिना, उपयोगकर्ताओं को थोड़ी देर के लिए रिपोर्ट का उपयोग करने के बाद यह त्रुटि मिलती है: क्रिस्टल रिपोर्ट अपवाद: आपके सिस्टम व्यवस्थापक द्वारा कॉन्फ़िगर की गई अधिकतम रिपोर्ट प्रोसेसिंग जॉब सीमा – stillsmallvoice

+0

@stillsmallvoice स्थानीय के बजाय रिपोर्ट स्रोत के लिए फ़ील्ड का उपयोग करें परिवर्तनीय, और पृष्ठ 'निपटान()' ओवरराइड में इसका निपटान करें। –

0

में मैं विजुअल स्टूडियो 2008 पर पहले कि समस्या थी, स्थापित करने क्रिस्टल रिपोर्ट बुनियादी सर्विस पैक 1 समस्या

0

मैं भी है कि समस्या थी हल, वहाँ एक और Webcontrol क्रिस्टल के साथ हस्तक्षेप नहीं है, तो जाँच (कॉलबैक समस्या जावास्क्रिप्ट? मुझे यकीन नहीं है)। मेरे विशिष्ट मामले में, उसी पृष्ठ में डालने पर डार्ट फ़ाइल अपलोड और क्रिस्टल अच्छी तरह से नहीं मिला था।

4
if (!Page.IsPostBack) 
{ 
    //Write your Report display code 

    crystalRep.Load(Server.MapPath("DueFD.rpt")); 
    crystalRep.SetDatabaseLogon(DB_UId, DB_Pass, Serv_Name, DB_Name); 
    CrystalReportViewer1.ReportSource = crystalRep; 

    // session code 
    ReportDocument doc = (ReportDocument)Session["ReportDocument"]; 
    CrystalReportViewer1.ReportSource = doc; 
} 
else 
{ 
    ReportDocument doc = (ReportDocument)Session["ReportDocument"]; 
    CrystalReportViewer1.ReportSource = doc; 
} 
5

मैन्युअल

this.Init += new System.EventHandler(this.Page_Init). 

साथ Page_Init() घटना और InitializeCompnent() में यह तार जोड़ Page_Init() करने के लिए Page_Load की सामग्री को ले जाएँ।

पेजइनआईट में if (!IsPostBack) स्थिति जोड़ें।

protected void Page_Init(object sender, EventArgs e) { 

    if (!IsPostBack) 
    { 
     ReportDocument crystalReportDocument = new ReportDocumment(); 
     crystalReportDocument.SetDataSource(DataTableHere); 
     _reportViewer.ReportSource = crystalReportDocument; 
     Session["ReportDocument"] = crystalReportDocument; 
    } 
    else 
    { 
      ReportDocument doc = (ReportDocument)Session["ReportDocument"]; 
      _reportViewer.ReportSource = doc; 
    } 
} 
+0

धन्यवाद।, सबसे अच्छा जवाब। – Ramunas

0

मैंने पेज लोडिंग के बजाय पेज_इनिट में सभी लोडिंग रिपोर्ट डाल दी। और यह ठीक से काम करता है।

0

मेरे लिए यह ठीक काम करता है जब तक कि मैंने 13.0.1 से 13.0.10 तक अपग्रेड नहीं किया, तो स्पष्ट रूप से कुछ बदल गया।

मैंने उपर्युक्त समाधान की कोशिश की है लेकिन यह इस तथ्य से जटिल है कि हम रिपोर्ट पैरामीटर अपडेट करने के लिए वापस पोस्ट करते हैं, और यदि आप पृष्ठ लोड पर रिपोर्ट पैरामीटर सेट नहीं करते हैं, तो रीफ्रेश विफल हो जाता है। तो आज के रूप में मुझे पेज लोड में कुछ भी किए बिना काम नहीं मिला है।

मुझे संदेह है कि मुझे बदले गए param मानों की जांच करने के लिए कुछ तर्क जोड़ना पड़ सकता है और यदि कोई बदल गया है तो रिपोर्ट को केवल ताज़ा करें।

1

Page_Init Page_Load के बजाय और रिपोर्ट में रखो रिपोर्ट स्रोत Page_Load मैं इसे शायद काम करता है

1

यह मेरे लिए काम करता है लगता है पैरामीटर !!

ReportDocument rd = new ReportDocument(); 

     protected void Page_Load(object sender, EventArgs e) 
     {   
      string rptpath = WebConfigurationManager.AppSettings["ReportPath"].Replace("{TID}", Convert.ToString(Session["TID"])); 
      rd.Load(rptpath); 

      DataTable dtable = TemplateModel.LoadChequeData(Convert.ToString(Session["CID"])); 
      rd.SetDataSource(dtable);   
     } 

     protected void Page_Init(object sender, EventArgs e) 
     { 
      CrystalReportViewer1.ReportSource = rd; 
     } 
0

मेरे पास साझा करने के लिए कुछ दृष्टिकोण है। मैंने सरल सीआर रैपर विकसित किया जो क्रिस्टल रिपोर्ट प्रस्तुत करने में मदद कर सकता है। इस कोड का प्रयोग इस प्रकार करें। कृपया कोड के किसी भी हिस्से को संशोधित करने के लिए स्वतंत्र महसूस करें। लिंक डाउनलोड करें https://1drv.ms/u/s!AlTLBrnU_bLUiaoUxcxNiRCZRQjWng

और नमूना सीआर रैपर वर्ग का उपयोग करके रैपर का उपयोग कैसे करें enter code here IDISposable इंटरफ़ेस लागू करता है।Page_Init में रिपोर्ट स्रोत सेट करें और पेज_लोड ईवेंट में पैरामीटर रिपोर्ट करें और पेज_उन्लोड ईवेंट में रिपोर्ट दस्तावेज़ का निपटान करें।
दूसरी विधि स्थिर वर्ग का उपयोग करती है और अंत में रिपोर्ट दस्तावेज़ का निपटान करते हुए रिपोर्ट प्रस्तुत करती है। रिपोर्ट स्रोत सत्र चर में सहेजा जाना चाहिए। कृपया ध्यान रखें कि स्थिर विधि का उपयोग करते हुए दूसरी विधि उच्च ट्रैफ़िक वेब एप्लिकेशन में वास्तव में उपयुक्त नहीं है। टकराव तब होगा जब दो उपयोगकर्ता एक ही समय में कोई रिपोर्ट चलाएंगे।

विधि 1

using System; 
using System.Linq; 
using CrystalDecisions.Shared; 
using System.Configuration; 
using System.Web.Configuration; 
using WebReports.Models.Helpers.CrystalReports; //Reference to CR wrapper 


namespace YourNamespace 
{ 
    public partial class ReportForm : System.Web.UI.Page 
    { 

     protected string _serverName; 
     protected string _databaseName; 
     protected string _schemaName; 
     protected string _userId; 
     protected string _userPassword; 
     protected bool _integratedSecurity; 
     protected string _databaseType; 
     //Wrapper Report Document 
     protected CReportDocument _reportDocument; 

     /// <summary> 
     /// Load report 
     /// </summary> 
     /// <param name="sender"></param> 
     /// <param name="e"></param> 
     protected void Page_Init(object sender, EventArgs e) 
     { 
      //Wrapper object 
      this._reportDocument = new CReportDocument(); 

      //These settings should be initialized from i.e. web.config in Page_PreInit 

      this._reportDocument.ServerName = this._serverName; 
      this._reportDocument.DatabaseName = String.Empty; 
      this._reportDocument.SchemaName = this._schemaName; 
      this._reportDocument.DatabaseType = CReportDatabaseType.ORACLE; 
      this._reportDocument.UserId = this._userId; 
      this._reportDocument.UserPassword = this._userPassword; 
      this._reportDocument.IntegratedSecurity = false; 


      //Get report name from query string. Define Your own method to get report name 
      var parReportName = Request.QueryString["reportname"]; 

      if (String.IsNullOrEmpty(parReportName)) 
      { 
       lblConfigError.Text = "Crystal Report name is not being provided."; 
       return; 
      } 

      //Set Report file 
      this._reportDocument.ReportFile = Server.MapPath("~/ReportFiles/") + parReportName; 
      //Set Report documant 
      this._reportDocument.SetReportDocument(); 
      //Get Report Document 
      crViewer.ReportSource = this._reportDocument.GetReportDocument(); 

     } 

     protected void Page_Load(object sender, EventArgs e) 
     { 

      CReportParameter reportParameter; 

      //Get parameters Your own method to provide report parameters 
      var parFimYear = RouteData.Values["par1"]; 
      var parFimCityCode = RouteData.Values["par2"]; 

      if (par1 == null || par2 == null) 
      { 
       lblConfigError.Text = "Crystal Report parameters are not being provided."; 
       return; 
      } 

      //Define Report Parameter 
      reportParameter = new CReportParameter(); 
      reportParameter.ParameterName = "@parYear"; 
      reportParameter.ParameterValue = parFimYear; 
      reportParameter.crParameterValueKind = ParameterValueKind.StringParameter; 
      _reportDocument.AddCReportParameter(reportParameter); 

      reportParameter = new CReportParameter(); 
      reportParameter.ParameterName = "@parCityCode"; 
      reportParameter.ParameterValue = parFimCityCode; 
      reportParameter.crParameterValueKind = ParameterValueKind.StringParameter; 
      _reportDocument.AddCReportParameter(reportParameter); 

      //Set report parameters 
      this._reportDocument.SetReportParameters(); 

     } 

     protected void Page_Unload(object sender, EventArgs e) 
     { 
      this._reportDocument.Dispose(); 
     } 

    } 
} 

विधि 2

using System; 
using System.Linq; 
using CrystalDecisions.Shared; 
using System.Configuration; 
using System.Web.Configuration; 
using CrystalDecisions.CrystalReports.Engine; 
using WebReports.Models.Helpers.CrystalReports; //Reference to CR wrapper 

namespace YourNamespace 
{ 
    public partial class ReportForm : System.Web.UI.Page 
    { 

     protected string _serverName; 
     protected string _databaseName; 
     protected string _schemaName; 
     protected string _userId; 
     protected string _userPassword; 
     protected bool _integratedSecurity; 
     protected string _databaseType; 

     /// <summary> 
     /// Load report 
     /// </summary> 
     /// <param name="sender"></param> 
     /// <param name="e"></param> 
     protected void Page_Init(object sender, EventArgs e) 
     { 
      CReportParameter reportParameter; 

      //These settings should be initialized from i.e. web.config in Page_PreInit 

      if (!IsPostBack) 
      { 
       if (this._databaseType == CReportDatabaseType.ORACLE.ToString()) 
       { 
        //static wrapper class 
        CReportDocumentManager.ServerName = this._serverName; 
        CReportDocumentManager.DatabaseName = String.Empty; 
        CReportDocumentManager.SchemaName = this._schemaName; 
        CReportDocumentManager.DatabaseType = CReportDatabaseType.ORACLE; 
        CReportDocumentManager.UserId = this._userId; 
        CReportDocumentManager.UserPassword = this._userPassword; 
        CReportDocumentManager.IntegratedSecurity = false; 

        //Get report name from query string. Define Your own method to get report name 
        var parReportName = Request.QueryString["reportname"]; 

        if (String.IsNullOrEmpty(parReportName)) 
        { 
         lblConfigError.Text = "Crystal Report name is not being provided."; 
         return; 
        } 
         //get par1. Your own method to provide report parameters. This is from MVC application 
         var par1 = RouteData.Values["par1"]; 
         //get par2 
         var par2 = RouteData.Values["par2"]; 

         if (par1 == null || par2 == null) 
         { 
          lblConfigError.Text = "Crystal Report parameters are not being provided."; 
          return; 
         } 

         reportParameter = new CReportParameter(); 
         reportParameter.ParameterName = "@parYear"; 
         reportParameter.ParameterValue = par1; 
         reportParameter.CReportParameterValueKind = ParameterValueKind.StringParameter; 
         CReportDocumentManager.AddCReportParameter(reportParameter); 

         reportParameter = new CReportParameter(); 
         reportParameter.ParameterName = "@parCityCode"; 
         reportParameter.ParameterValue = par2; 
         reportParameter.CReportParameterValueKind = ParameterValueKind.StringParameter; 
         CReportDocumentManager.AddCReportParameter(reportParameter); 



        CReportDocumentManager.ReportFile = Server.MapPath("~/ReportFiles/") + parReportName; 
        ReportDocument doc = CReportDocumentManager.GetCReportDocument(); 
        crViewer.ReportSource = doc; 
        Session[parReportName] = doc; 

       } 
      } 
      else 
      { 
       var parReportName = Request.QueryString["reportname"]; 
       ReportDocument doc = (ReportDocument)Session[parReportName]; 
       crViewer.ReportSource = doc; 

      }     
     } 

    } 
} 
संबंधित मुद्दे