Filtering data in the ReportViewer using a drop down control

P

Paul S

Hi

I have a ASP.Net page with a ReportControl and a drop down control to filter
the data shown in the report.

However I cannot get any data displayed. To illustrate the problem I have
made a small demo. It is based on the AdventureWorks database.
The StateProvince table is displayed in the report and the ContryRegion
table is the source for the drop down control.

Here's my page

<body>
<form id="form1" runat="server">
<div>

</div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="CountryRegionCode" Height="23px" Width="202px">
</asp:DropDownList>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="SELECT [CountryRegionCode], [Name] FROM
[Person].[CountryRegion]">
</asp:SqlDataSource>
<br />
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="613px">
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="AdventureWorksDataSet_StateProvince" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"

TypeName="AdventureWorksDataSetTableAdapters.StateProvinceTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
Name="CountryRegionCode"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</form>
</body>

and here's my report

<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="AdventureWorksConnectionString">
<rd:DataSourceID>33fcbe7b-2c22-40af-8009-52a28721a8e8</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>
</DataProvider>
<ConnectString>
</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<InteractiveHeight>11in</InteractiveHeight>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:GridSpacing>0.25cm</rd:GridSpacing>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>2.5cm</RightMargin>
<LeftMargin>2.5cm</LeftMargin>
<BottomMargin>2.5cm</BottomMargin>
<rd:ReportID>03bcd1a3-b78c-49a9-b391-c2aff2a867fb</rd:ReportID>
<PageWidth>21cm</PageWidth>
<DataSets>
<DataSet Name="AdventureWorksDataSet_StateProvince">
<Fields>
<Field Name="StateProvinceID">
<DataField>StateProvinceID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="StateProvinceCode">
<DataField>StateProvinceCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CountryRegionCode">
<DataField>CountryRegionCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Name">
<DataField>Name</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>AdventureWorksConnectionString</DataSourceName>
<CommandText>SELECT StateProvinceID, StateProvinceCode,
CountryRegionCode, Name
FROM Person.StateProvince
WHERE (CountryRegionCode = @CountryRegionCode)</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>AdventureWorksDataSet</rd:DataSetName>
<rd:TableName>StateProvince</rd:TableName>
<rd:TableAdapterName>StateProvinceTableAdapter</rd:TableAdapterName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
<rd:TableAdapterGetDataMethod>GetData</rd:TableAdapterGetDataMethod>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<Width>16.28968cm</Width>
<Body>
<ColumnSpacing>1cm</ColumnSpacing>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<Width>12.69841cm</Width>
<Style>
<Color>SteelBlue</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>20pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>true</CanGrow>
<Height>0.91429cm</Height>
<Value>Report1</Value>
</Textbox>
<Table Name="table1">
<DataSetName>AdventureWorksDataSet_StateProvince</DataSetName>
<Top>1.5cm</Top>
<TableGroups>
<TableGroup>
<Grouping Name="table1_StateProvinceID">
<GroupExpressions>

<GroupExpression>=Fields!StateProvinceID.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!StateProvinceID.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox7">
<rd:DefaultName>textbox7</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>5</ZIndex>
<CanGrow>true</CanGrow>
<Value>
</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox8">
<rd:DefaultName>textbox8</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>4</ZIndex>
<CanGrow>true</CanGrow>
<Value>
</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox9">
<rd:DefaultName>textbox9</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>3</ZIndex>
<CanGrow>true</CanGrow>
<Value>
</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.53333cm</Height>
</TableRow>
</TableRows>
</Header>
</TableGroup>
</TableGroups>
<Width>10.28968cm</Width>
<Details>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="StateProvinceCode">
<rd:DefaultName>StateProvinceCode</rd:DefaultName>
<Style>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>2</ZIndex>
<CanGrow>true</CanGrow>
<Value>=Fields!StateProvinceCode.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="CountryRegionCode">
<rd:DefaultName>CountryRegionCode</rd:DefaultName>
<Style>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>true</CanGrow>
<Value>=Fields!CountryRegionCode.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Name">
<rd:DefaultName>Name</rd:DefaultName>
<Style>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!Name.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.53333cm</Height>
</TableRow>
</TableRows>
</Details>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox4">
<rd:DefaultName>textbox4</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>SteelBlue</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontSize>11pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>8</ZIndex>
<CanGrow>true</CanGrow>
<Value>State Province Code</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox5">
<rd:DefaultName>textbox5</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>SteelBlue</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontSize>11pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>7</ZIndex>
<CanGrow>true</CanGrow>
<Value>Country Region Code</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox6">
<rd:DefaultName>textbox6</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>SteelBlue</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontSize>11pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>6</ZIndex>
<CanGrow>true</CanGrow>
<Value>Name</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.55873cm</Height>
</TableRow>
</TableRows>
<RepeatOnNewPage>true</RepeatOnNewPage>
</Header>
<TableColumns>
<TableColumn>
<Width>3.25cm</Width>
</TableColumn>
<TableColumn>
<Width>4.5cm</Width>
</TableColumn>
<TableColumn>
<Width>2.53968cm</Width>
</TableColumn>
</TableColumns>
</Table>
</ReportItems>
<Height>3.12539cm</Height>
</Body>
<Language>en-US</Language>
<TopMargin>2.5cm</TopMargin>
<PageHeight>29.7cm</PageHeight>
</Report>
 
S

Steven Cheng [MSFT]

Hi Paul,

From your description, you use Web ReportViewer control to display rdlc
client report on ASP.NET page and the report use a datasource which has a
control parameter from a dropdownlist. However, you found that when you
change dropdownlist selected value, the report doesn't refresh, correct?

Based on my local test, I think you need to add some code which refresh the
client report when the dropdownlist's selectedIndex changed. For example,
you can simply add the following code in "SelectedIndexChanged" event:

=====================================

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs
e)
{
ReportViewer1.LocalReport.Refresh();
}

=========================

Here is the test page's aspx template:

===========================================
<form id="form1" runat="server">
<div>

<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>

</div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="400px">
<LocalReport ReportPath="PersonReport.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="testdbDataSet_persons" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="testdbDataSetTableAdapters.personsTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
DefaultValue="1" Name="id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
</form>

====================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
Thread-Topic: Filtering data in the ReportViewer using a drop down control
thread-index: AciYoA+7+I8LQKWSQbmB8LA/Psnk2g==
X-WBNR-Posting-Host: 87.48.170.130
From: =?Utf-8?B?UGF1bCBT?= <[email protected]>
Subject: Filtering data in the ReportViewer using a drop down control
Date: Mon, 7 Apr 2008 04:11:00 -0700
Hi

I have a ASP.Net page with a ReportControl and a drop down control to filter
the data shown in the report.

However I cannot get any data displayed. To illustrate the problem I have
made a small demo. It is based on the AdventureWorks database.
The StateProvince table is displayed in the report and the ContryRegion
table is the source for the drop down control.

Here's my page

<body>
<form id="form1" runat="server">
<div>

</div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="CountryRegionCode" Height="23px" Width="202px">
</asp:DropDownList>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="SELECT [CountryRegionCode], [Name] FROM
[Person].[CountryRegion]">
</asp:SqlDataSource>
<br />
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="613px">
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="AdventureWorksDataSet_StateProvince" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"

TypeName="AdventureWorksDataSetTableAdapters.StateProvinceTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
Name="CountryRegionCode"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</form>
</body>

and here's my report

<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefin ition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="AdventureWorksConnectionString">
<ConnectionProperties>
<DataProvider>
</DataProvider>
<ConnectString>
</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<InteractiveHeight>11in</InteractiveHeight>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:GridSpacing>0.25cm</rd:GridSpacing>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>2.5cm</RightMargin>
<LeftMargin>2.5cm</LeftMargin>
<BottomMargin>2.5cm</BottomMargin>
<rd:ReportID>03bcd1a3-b78c-49a9-b391-c2aff2a867fb</rd:ReportID>
<PageWidth>21cm</PageWidth>
<DataSets>
<DataSet Name="AdventureWorksDataSet_StateProvince">
<Fields>
<Field Name="StateProvinceID">
<DataField>StateProvinceID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="StateProvinceCode">
<DataField>StateProvinceCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CountryRegionCode">
<DataField>CountryRegionCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Name">
<DataField>Name</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>AdventureWorksConnectionString</DataSourceName>
<CommandText>SELECT StateProvinceID, StateProvinceCode,
CountryRegionCode, Name
FROM Person.StateProvince
WHERE (CountryRegionCode = @CountryRegionCode)</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>AdventureWorksDataSet</rd:DataSetName>
<rd:TableName>StateProvince</rd:TableName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
 
P

Paul S

You're absolutely right Steven - that solved my problem. --

Thanks a lot
Paul S


Steven Cheng said:
Hi Paul,

From your description, you use Web ReportViewer control to display rdlc
client report on ASP.NET page and the report use a datasource which has a
control parameter from a dropdownlist. However, you found that when you
change dropdownlist selected value, the report doesn't refresh, correct?

Based on my local test, I think you need to add some code which refresh the
client report when the dropdownlist's selectedIndex changed. For example,
you can simply add the following code in "SelectedIndexChanged" event:

=====================================

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs
e)
{
ReportViewer1.LocalReport.Refresh();
}

=========================

Here is the test page's aspx template:

===========================================
<form id="form1" runat="server">
<div>

<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>

</div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="400px">
<LocalReport ReportPath="PersonReport.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="testdbDataSet_persons" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="testdbDataSetTableAdapters.personsTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
DefaultValue="1" Name="id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
</form>

====================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
Thread-Topic: Filtering data in the ReportViewer using a drop down control
thread-index: AciYoA+7+I8LQKWSQbmB8LA/Psnk2g==
X-WBNR-Posting-Host: 87.48.170.130
From: =?Utf-8?B?UGF1bCBT?= <[email protected]>
Subject: Filtering data in the ReportViewer using a drop down control
Date: Mon, 7 Apr 2008 04:11:00 -0700
Hi

I have a ASP.Net page with a ReportControl and a drop down control to filter
the data shown in the report.

However I cannot get any data displayed. To illustrate the problem I have
made a small demo. It is based on the AdventureWorks database.
The StateProvince table is displayed in the report and the ContryRegion
table is the source for the drop down control.

Here's my page

<body>
<form id="form1" runat="server">
<div>

</div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="CountryRegionCode" Height="23px" Width="202px">
</asp:DropDownList>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="SELECT [CountryRegionCode], [Name] FROM
[Person].[CountryRegion]">
</asp:SqlDataSource>
<br />
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="613px">
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="AdventureWorksDataSet_StateProvince" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"

TypeName="AdventureWorksDataSetTableAdapters.StateProvinceTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
Name="CountryRegionCode"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</form>
</body>

and here's my report

<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefin ition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="AdventureWorksConnectionString">
<ConnectionProperties>
<DataProvider>
</DataProvider>
<ConnectString>
</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<InteractiveHeight>11in</InteractiveHeight>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:GridSpacing>0.25cm</rd:GridSpacing>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>2.5cm</RightMargin>
<LeftMargin>2.5cm</LeftMargin>
<BottomMargin>2.5cm</BottomMargin>
<rd:ReportID>03bcd1a3-b78c-49a9-b391-c2aff2a867fb</rd:ReportID>
<PageWidth>21cm</PageWidth>
<DataSets>
<DataSet Name="AdventureWorksDataSet_StateProvince">
<Fields>
<Field Name="StateProvinceID">
<DataField>StateProvinceID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="StateProvinceCode">
<DataField>StateProvinceCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CountryRegionCode">
<DataField>CountryRegionCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Name">
<DataField>Name</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>AdventureWorksConnectionString</DataSourceName>
<CommandText>SELECT StateProvinceID, StateProvinceCode,
CountryRegionCode, Name
FROM Person.StateProvince
WHERE (CountryRegionCode = @CountryRegionCode)</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>AdventureWorksDataSet</rd:DataSetName>
<rd:TableName>StateProvince</rd:TableName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<Width>16.28968cm</Width>
<Body>
<ColumnSpacing>1cm</ColumnSpacing>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<Width>12.69841cm</Width>
<Style>
<Color>SteelBlue</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>20pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>true</CanGrow>
<Height>0.91429cm</Height>
<Value>Report1</Value>
</Textbox>
<Table Name="table1">
<DataSetName>AdventureWorksDataSet_StateProvince</DataSetName>
<Top>1.5cm</Top>
<TableGroups>
<TableGroup>
<Grouping Name="table1_StateProvinceID">
<GroupExpressions>

<GroupExpression>=Fields!StateProvinceID.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox7">
<rd:DefaultName>textbox7</rd:DefaultName>
<Style>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontFamily>Tahoma</FontFamily>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>5</ZIndex>
<CanGrow>true</CanGrow>
<Value>
</Value>
</Textbox>
</ReportItems>
</TableCell>
 
S

Steven Cheng [MSFT]

You're welcome:)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
 
P

Paul S

Hi again
When I move this into my production code my subreports failed. I tried to
change my Page_load method so that this is always done - not just when is not
Postback

this.ReportViewer1.LocalReport.SubreportProcessing +=
new
Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing);

When I select a different value in the drop down box I see that
SubreportProcessing is null in the Page_Load eventhandler.

- and everything works now !

What's the explanation for this
 
S

Steven Cheng [MSFT]

Hi Paul,

I haven't expected the subreport scenario here. Yes, I know that for sub
report in rdlc, we need to ad "SubReportProcessing" handler and add
datasource for subreport. As you said that the event handler is Null, how
did you originally attached the event handler? I agree that add event
wireup code in Page_Load is reasonable for event handler to be registered
on every request.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: =?Utf-8?B?UGF1bCBT?= <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: RE: Filtering data in the ReportViewer using a drop down control
Date: Tue, 8 Apr 2008 23:47:01 -0700
 
P

Paul S

Hi Steven
Originally I did it also in the Page_load but

if (!this.IsPostBack) ..

I expected it only to be nescessary do be done once
 
S

Steven Cheng [MSFT]

Thanks for your quick reply paul,

for ASP.NET webcontrol, if you attach even handler in code, you need to
make sure the event handler attaching code get executed in each request(not
only in the first load).

Actually, this is also a common requirement for dynamically created
webserver control. You need to create the control instance and attach
event handler(if necessary) in each page request(in Init or Load). Only
attach once (when !IsPostBack) is not enough because in each request/load,
it will recreate the control structure and check event handler:

http://support.microsoft.com/kb/317794

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
=
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
<[email protected]>
<[email protected]>
<[email protected]>
 
P

Paul S

Thanks Steven
I got everything up and running now
One small comment - error tracking is really hard when the subreport fails
to load - not much help is provided in the error messages. Hope this gets
better in the future.
 
S

Steven Cheng [MSFT]

Thanks for your followup and the sincere comments.

For the subreport error handling, I also suggest you submit it to our
feedback center so that the DEV team can also get more on this:

https://connect.microsoft.com/feedback/default.aspx?SiteID=210&wa=wsignin1.0

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Thread-Topic: Filtering data in the ReportViewer using a drop down control
thread-index: Acigd0F3MvAaE6dgRo+tkBu55AHCpg==
X-WBNR-Posting-Host: 87.48.170.130
From: =?Utf-8?B?UGF1bCBT?= <[email protected]>
Subject: RE: Filtering data in the ReportViewer using a drop down control
Date: Thu, 17 Apr 2008 03:39:04 -0700
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top