1

我有一个Dataset绑定Reportviewer,我dataset有两个参数,在报告中通常会显示响亮的数据,问题是当我以新值传递参数时reportviewer,我单击搜索Button之前的数据reportviewer是否有任何变化。表示不会显示更新的搜索数据!

这是我的代码:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
            mysession() 
            ReportViewer1.ProcessingMode = ProcessingMode.Local 
            Dim rep As LocalReport = ReportViewer1.LocalReport 
            rep.ReportPath = "Leaving Report.rdlc" 
            Dim ds1 As DataSet = GetData() 

            Dim EMpReplt As New ReportDataSource() 
            EMpReplt.Name = "ProlDataSet_Lrepoert" 
            EMpReplt.Value = ds1.Tables("EMPData") 
            rep.DataSources.Add(EMpReplt) 
End sub 

 Private Function GetSalesData() 
        Dim ds As New DataSet 
        Dim sql As String = "select * from laeve where Status='" & DropDownList1.SelectedValue & "' and Agent='" & Session("Agence") & "'" 
            Dim command As New SqlCommand(sql,con) 
            Dim mysqlAdapter As New SqlDataAdapter(command) 
            mysqlAdapter.Fill(ds, "EMPData") 
            mysqlAdapter.Dispose() 
            command.Dispose() 
        End Using 
        Return ds 
    End Function 
 End Sub 


Protected Sub Search_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click 
    ReportViewer1.LocalReport.Refresh() 
End Sub
4

1 回答 1

0

Try to place the .IsPostBack Using the WebForms ReportViewer Control

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
            mysession() 
   If Not Page.IsPostBack Then
            ReportViewer1.ProcessingMode = ProcessingMode.Local 
            Dim rep As LocalReport = ReportViewer1.LocalReport 
            rep.ReportPath = "Leaving Report.rdlc" 
            Dim ds1 As DataSet = GetData() 

            Dim EMpReplt As New ReportDataSource() 
            EMpReplt.Name = "ProlDataSet_Lrepoert" 
            EMpReplt.Value = ds1.Tables("EMPData") 
            rep.DataSources.Add(EMpReplt) 
     End if
End sub 
于 2013-02-09T06:51:58.097 回答