2011-01-10 3 views
1

Обратитесь к сообщениюКак установить параметр в отчете о кристалле в asp .net?

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-string-parameter.htm

ASP .NET будет автоматически иметь текстовое поле или DateTimePicker для ввода

Однако после ввода и обновления отчета, текстовое поле и кнопка отправки исчезают

  1. Как показать текстовое поле и кнопку еще раз?
  2. А функция в посте не работает после прохождения значения даты и времени toshortdatestring() из календаря управления

ответ

1

Вы можете передать параметр в отчеты хрустальных вручную. Таким образом, вы можете создать форму своего собственного параметра, и вы можете обрабатывать ввод пользователя, чтобы отправить его в отчет. Вот отрывок, чтобы показать вам, как вы можете сделать это:

ReportDocument doc = new ReportDocument(); 
doc.Load(Path.Combine(basePath, report.Name + ".rpt")); 
doc.SetDataSource(dataTable); 

// set parameters defined in Paramenter fields inside the rpt 
var value = new ParameterDiscreteValue(); 
value.Value = valueYouWantToPass; 
doc.ParameterFields["nameOfTheParamenterField"].CurrentValues.Add(value); 
1

Try:

 Imports CrystalDecisions 
     Imports CrystalDecisions.CrystalReports 
     Imports CrystalDecisions.CrystalReports.Engine 
     Imports CrystalDecisions.Shared 

     Dim RptDoc As New ReportDocument() 
     Dim CrTables As Tables 
     Dim CrTable As Table 
     Dim crtableLogoninfo As New TableLogOnInfo 
     RptDoc.Load(Server.MapPath(ReportFullFilename)) 

        With crConnectionInfo 
         .ServerName = "myServer" 
         .DatabaseName = "myDatabase" 
         .UserID = "myUserID" 
         .Password = "myPassword" 
        End WITH 

     CrTables = RptDoc.Database.Tables 

     For Each CrTable In CrTables 
      crtableLogoninfo = CrTable.LogOnInfo 
      crtableLogoninfo.ConnectionInfo = crConnectionInfo 
      CrTable.ApplyLogOnInfo(crtableLogoninfo) 
     Next 

     RptDoc.SetDatabaseLogon(crConnectionInfo.UserID, crConnectionInfo.Password, crConnectionInfo.ServerName, crConnectionInfo.ServerName) 


     RptDoc.SetParameterValue("FromDate", FromDatePicker.SelectedDate) 
     RptDoc.SetParameterValue("ThruDate", ToDatePicker.SelectedDate) 

     Dim stream As New BinaryReader(RptDoc.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)) 
     Response.ClearContent() 
     Response.ClearHeaders() 
     Response.ContentType = "application/pdf" 
     Response.AddHeader("content-disposition", Convert.ToString("attachment; filename=") & downloadAsFilename) 
     Response.AddHeader("content-length", stream.BaseStream.Length.ToString()) 
     Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length))) 
     Response.Flush() 
     Response.Close() 
Смежные вопросы