本文介绍了将参数从页面链接传递到报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何将一个页面上的3个参数值传递给报表或CrystalReportViewer。 报告是C#中的网络报告 报告中的参数字段为:  的CampaignID    BEGINDATE    EndDate 所以说链接页面网址如下所示: http://localhost/reports/campaign_report/default.aspx?CampaignID = 61325& BeginDate = 1/1/2006& EndDate = 1/2/2006 我希望将这些值传递给报告并绕过参数提示页面。 当我运行此链接时,报告查看器页面显示"缺少参数" 我是否需要在default.aspx.cs页面添加内容? ------------------------------------------ ------------------ protected void Page_Load( object sender, EventArgs e) {     Parameter.Field1 =(CampaignID);      Parameter.Value1  = Request.QueryString("CampaignID");       ... ?? } -------- ----------------------------------- 非常感谢任何帮助? 谢谢你,杰森 Do I need to add something to the default.aspx.cs page?------------------------------------------------------------protected void Page_Load(object sender, EventArgs e){     Parameter.Field1 = (CampaignID);     Parameter.Value1 = Request.QueryString("CampaignID");     ...??}-------------------------------------------Any help would be greatly appreciated?Thank you,Jason 推荐答案这是VB中的一个示例。 TextBox1和TextBox2来自上一页。here's an example in VB. TextBox1 and TextBox2 are from the previous page. Dim gv As StringDim gv As String Dim gv1 As StringDim gv1 As String gv = " 11/15/05"gv = "11/15/05" gv1 = " 11/15/05"gv1 = "11/15/05" 如果 不 Page.PreviousPage Nothing 然后If Not Page.PreviousPage Is Nothing Then Dim SourceTextBox As TextBoxDim SourceTextBox As TextBox SourceTextBox = CType (PreviousPage.FindControl( " TextBox1" ),TextBox)SourceTextBox = CType(PreviousPage.FindControl("TextBox1"), TextBox) If 不 SourceTextBox Nothing 然后If Not SourceTextBox Is Nothing Then gv = SourceTextBox.Textgv = SourceTextBox.Text 结束 如果End If 结束 如果End If If 不 Page.PreviousPage Nothing 然后If Not Page.PreviousPage Is Nothing Then Dim SourceTextBox2 As TextBoxDim SourceTextBox2 As TextBox SourceTextBox2 = CType (PreviousPage.FindControl( "TextBox2" ),TextBox)SourceTextBox2 = CType(PreviousPage.FindControl("TextBox2"), TextBox) 如果 不 SourceTextBox2 Nothing 然后If Not SourceTextBox2 Is Nothing Then gv1 = SourceTextBox2.Textgv1 = SourceTextBox2.Text 结束 如果End If End 如果End If Dim paramFields As New CrystalDecisions.Shared.ParameterFields()Dim paramFields As New CrystalDecisions.Shared.ParameterFields() Dim paramField As New CrystalDecisions.Shared.ParameterField()Dim paramField As New CrystalDecisions.Shared.ParameterField() Dim discreteVal As 新 CrystalDecisions.Shared.ParameterDiscreteValu e()Dim discreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue() Dim paramField2 As New CrystalDecisions.Shared。 ParameterField()Dim paramField2 As New CrystalDecisions.Shared.ParameterField() Dim discreteVal2 As New CrystalDecisions.Shared。 ParameterDiscreteValue()Dim discreteVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue() paramField.ParameterFieldName = " @ EnterBeginningDate"paramField.ParameterFieldName = "@EnterBeginningDate" Dim gva As DateTime = DateTime.Parse(gv)Dim gva As DateTime = DateTime.Parse(gv) discreteVal.Value = gvadiscreteVal.Value = gva paramField.CurrentValues.Add(discreteVal)paramField.CurrentValues.Add(discreteVal) paramFields.Add(paramField)paramFields.Add(paramField) paramField2.ParameterFieldName = " @ EnterEndingDate"paramField2.ParameterFieldName = "@EnterEndingDate" Dim gv1a As DateTime = DateTime.Parse(gv1)Dim gv1a As DateTime = DateTime.Parse(gv1) discreteVal2.Value = gv1adiscreteVal2.Value = gv1a paramField2.CurrentValues.Add(discreteVal2)paramField2.CurrentValues.Add(discreteVal2) paramFields.Add(paramField2 )paramFields.Add(paramField2) '将参数字段集合设置为查看器控件。' Set the parameter fields collection into the viewer control. CrystalReportViewer1.ParameterFieldInfo = paramFieldsCrystalReportViewer1.ParameterFieldInfo = paramFields - Carl 这篇关于将参数从页面链接传递到报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 22:07