I know this issue has been addressed a few times, but I'm having issues still with my attempt. I'm trying to avoid using the wizard for my dataset and do everything programatically.
Here's what I have in the report code-behind:
And here's what I have on my ASPX page calling the report:
And the parameter value never makes it to the report, so I get a blank one. If I execute the report and statically replace the Me.Parameter.Value with a static string value, everything works perfectly.
I've also tried many other variations of the code above and even tried creating a new instantce of my RosterReport and then binding it to the reportviewer to no avail.
Edit: It seems like the initial report is getting instantiated, but a version of the report with the parameter values assigned is never created. I thought that was the purpose of "refresh report"
Any help would be greatly appreciated.
Here's what I have in the report code-behind:
Public Sub New() |
InitializeComponent() |
Try |
Dim connMAS As SqlConnection = New SqlConnection() |
Dim cmd As SqlCommand |
Dim commLoadPortalUserInfo As SqlCommand = connMAS.CreateCommand() |
connMAS.ConnectionString = Convert.ToString("some connection string") |
connMAS.Open() |
cmd = connMAS.CreateCommand() |
cmd.CommandText = "storedprocedurename" |
cmd.CommandType = CommandType.StoredProcedure |
cmd.Parameters.Add("@CompanyID", SqlDbType.VarChar) |
cmd.Parameters("@CompanyID").Value = Me.ReportParameters("CompanyID").Value |
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd) |
Dim ds As DataSet = New DataSet |
da.Fill(ds) |
Me.DataSource = ds |
connMAS.Close() |
Catch ex As System.Exception |
System.Diagnostics.Debug.WriteLine(ex.Message) |
End Try |
End Sub |
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If (Not Page.IsPostBack) Then |
ReportViewer1.Report = New RosterReport() |
ReportViewer1.Report.ReportParameters(0).Value = "Value" |
ReportViewer1.RefreshReport() |
End If |
End Sub |
End Class |
I've also tried many other variations of the code above and even tried creating a new instantce of my RosterReport and then binding it to the reportviewer to no avail.
Edit: It seems like the initial report is getting instantiated, but a version of the report with the parameter values assigned is never created. I thought that was the purpose of "refresh report"
Any help would be greatly appreciated.