I have been forced to switch from the report server reports to the local type. I am using the report viewer control in web developer express.
In my server reports I was able to use parameters, for example
HAVING (Date_Completed BETWEEN @Start AND @End), this allowed me to enter the start and end dates at the top of the report page and then display the data within that range.
It is not working with the report viewer. Is there a way to add this functionality into it??
Ok so that link is what I want to do. I entered the code she wrote into a c# to vb converter. I pasted it in my page but it stays black, it does not turn red and blue like the other stuff. this is the code and the error I get:
Description:
An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.
Source Error:
Line 1:
Line 2:
Line 3: Imports System
Line 4: Imports System.Data
Line 5: Imports System.Data.SqlClient
I think you forgot the basics. Just put the code starting from the imports statement(on which the error was displayed) to the end of the code(right next to which the content tag starts) into script tag having the attributes of runat=server and language=vb.
By any means do you have a <DOCTYPE> declaration on your content page? Also just make sure that your <asp:Content> element in your page is the top most element. There should not be anything above it. For eg: a template would look like this :
cud you find out a solution for it .Even i have to use some report parameters ,either i can do it by using a dropdown or a text box ...is there any other way which you might have seen somewhere.
Protected Sub RunReport_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles RunReport.Click
Dim pub As Microsoft.Reporting.WebForms.ReportParameter
Dim puba As Microsoft.Reporting.WebForms.ReportParameter
Dim startdate
As DateTime = starttext.Text
Dim enddate As DateTime = endtext.TextDim num
As Microsoft.Reporting.WebForms.ReportParameter
num =
New ReportParameter("Assignment_Number", User.Identity.Name)
pub = New Microsoft.Reporting.WebForms.ReportParameter("Start", startdate)
I use 2 parameters, a start date and an end date. You of course have to create the parameters in your report with the same name. I used "start" and "end".
no thi is not whst i want here you are using a text box to enter the dates manually..but what i want is like a server report that you need not put a text box and the start end date calendar appears itself in the report no externally using a textbox.
joewb
Member
10 Points
70 Posts
use parameters in report viewer control
Aug 24, 2007 06:32 PM|LINK
I have been forced to switch from the report server reports to the local type. I am using the report viewer control in web developer express.
In my server reports I was able to use parameters, for exampleHAVING (Date_Completed BETWEEN @Start AND @End), this allowed me to enter the start and end dates at the top of the report page and then display the data within that range.
It is not working with the report viewer. Is there a way to add this functionality into it??
Suprotim Aga...
All-Star
15593 Points
1973 Posts
MVP
Re: use parameters in report viewer control
Aug 26, 2007 02:01 PM|LINK
http://www.codeproject.com/aspnet/ReportViewer.asp
HTH,
Suprotim Agarwal
Free Magazine for ASP.NET Developers
joewb
Member
10 Points
70 Posts
Re: use parameters in report viewer control
Aug 27, 2007 08:08 PM|LINK
Suprotim Agarwal,
Ok so that link is what I want to do. I entered the code she wrote into a c# to vb converter. I pasted it in my page but it stays black, it does not turn red and blue like the other stuff. this is the code and the error I get:
<%@ Page Language="VB" MasterPageFile="~/MasterPage2.master" Title="Untitled Page" %><%
@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.ApplicationBlocks.Data
Imports Microsoft.Reporting.WebForms
Public partial Class ReportViewerLocalMode
Inherits System.Web.UI.Page
Public String thisConnectionString =
ConfigurationManager.ConnectionStrings(
"aimoareportstring").ConnectionString
' I used the following statement to show if you have multiple
' input parameters, declare the parameter with the number
' of parameters in your application, ex. New SqlParameter(4) */
Public SearchValue() As SqlParameter = New SqlParameter(2) {}
Protected Sub RunReportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
'ReportViewer1.Visible is set to false in design mode'
ReportViewer1.Visible = True
Dim thisConnection As SqlConnection = New SqlConnection(thisConnectionString)
Dim thisDataSet As System.Data.DataSet = New System.Data.DataSet()
SearchValue(0) = New SqlParameter("@Start", starttext.text)
' Put the stored procedure result into a dataset */
thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
"assignbydate", SearchValue)
' or thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
' "assignbydate", starttext.text)
' if you only have 1 input parameter */
' Associate thisDataSet (now loaded with the stored
' procedure result) with the ReportViewer datasource */
ReportDataSource datasource = New
ReportDataSource("assignbydate_Inspection_Assignments",
thisDataSet.Tables(0))
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(datasource)
If thisDataSet.Tables(0).Rows.Count = 0 Then
lblMessage.Text = "Sorry, no records in this date range!"
End If
ReportViewer1.LocalReport.Refresh()
End Sub
End Class
<
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <span style="font-size: 16pt">Assignments By Date</span><br /> <asp:Label ID="Label1" runat="server" Text="Enter Start Date"></asp:Label> <asp:TextBox ID="starttext" runat="server"></asp:TextBox> <asp:Label ID="Label2" runat="server" Text="Enter End Date"></asp:Label> <asp:TextBox ID="endtext" runat="server"></asp:TextBox> <asp:Button ID="RunReport" runat="server" Text="Run Report" /><br /> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="400px" Visible="False" Width="756px"> <LocalReport ReportPath="Inspectors\assignments_bydate.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="assignbydate_Inspection_Assignments" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="assignbydateTableAdapters.Inspection_AssignmentsTableAdapter"></asp:ObjectDataSource></
asp:Content>Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.
Source Error:
Source File: /Inspectors/assignments bydate.aspx Line: 3
What do I need to fix??
dhimant
Star
8170 Points
1152 Posts
Re: use parameters in report viewer control
Sep 19, 2007 11:18 AM|LINK
I think you forgot the basics. Just put the code starting from the imports statement(on which the error was displayed) to the end of the code(right next to which the content tag starts) into script tag having the attributes of runat=server and language=vb.
Hope this will help.
Dhimant
Dhimant Trivedi
"When the going gets tough, tough gets going."
"Mark as Answer" the post(s) which helped you solve the problem
Suprotim Aga...
All-Star
15593 Points
1973 Posts
MVP
Re: use parameters in report viewer control
Sep 22, 2007 03:47 AM|LINK
By any means do you have a <DOCTYPE> declaration on your content page? Also just make sure that your <asp:Content> element in your page is the top most element. There should not be anything above it. For eg: a template would look like this :
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="Default1.aspx.cs" Inherits="Default1" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:content>
Free Magazine for ASP.NET Developers
tomari
Member
18 Points
10 Posts
Re: use parameters in report viewer control
Nov 27, 2007 09:05 AM|LINK
hi ,
cud you find out a solution for it .Even i have to use some report parameters ,either i can do it by using a dropdown or a text box ...is there any other way which you might have seen somewhere.
joewb
Member
10 Points
70 Posts
Re: use parameters in report viewer control
Nov 27, 2007 04:33 PM|LINK
I sure did and here is my code on the aspx page:
<script runat="server">
Protected Sub RunReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RunReport.Click Dim pub As Microsoft.Reporting.WebForms.ReportParameter Dim puba As Microsoft.Reporting.WebForms.ReportParameter Dim startdate As DateTime = starttext.Text Dim enddate As DateTime = endtext.TextDim num As Microsoft.Reporting.WebForms.ReportParameternum =
New ReportParameter("Assignment_Number", User.Identity.Name) pub = New Microsoft.Reporting.WebForms.ReportParameter("Start", startdate)puba =
New Microsoft.Reporting.WebForms.ReportParameter("End", enddate) Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter() {pub}) Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter() {puba}) Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter() {num})ReportViewer1.LocalReport.Refresh()
ReportViewer1.Visible =
True End Sub
</Script><
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <span style="font-size: 16pt">Assignments By Date</span><br /> <asp:Label ID="Label1" runat="server" Text="Enter Start Date"></asp:Label> <asp:TextBox ID="starttext" runat="server"></asp:TextBox> <asp:Label ID="Label2" runat="server" Text="Enter End Date"></asp:Label> <asp:TextBox ID="endtext" runat="server"></asp:TextBox> <asp:Button ID="RunReport" runat="server" Text="Run Report" OnClick="RunReport_Click" /><br /> <br /> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="1340px" Width="1076px" Visible="False"> <LocalReport ReportPath="Inspectors\assignments_bydate.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="assignbydate_Inspection_Assignments" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="assignbydateTableAdapters.Inspection_AssignmentsTableAdapter"></asp:ObjectDataSource></
asp:Content>I use 2 parameters, a start date and an end date. You of course have to create the parameters in your report with the same name. I used "start" and "end".
I hope this helps.
Joe
tomari
Member
18 Points
10 Posts
Re: use parameters in report viewer control
Dec 03, 2007 05:17 AM|LINK
no thi is not whst i want here you are using a text box to enter the dates manually..but what i want is like a server report that you need not put a text box and the start end date calendar appears itself in the report no externally using a textbox.
joewb
Member
10 Points
70 Posts
Re: use parameters in report viewer control
Dec 03, 2007 06:13 PM|LINK
Then I believe you could put a calendar control on your aspx page and have the query parameter = calendar1.selected value
Im no expert tho. I do recall watching something about the calendar controls in the help videos-they are very helpful.
Joe