ReportViewer/ObjectDataSource Problem

H

Houston Lucifer

I have a report viewer on my webpage and it is linked to an objectdatasource.
The parameter is a control on the form (Dropdownlist). But, when i change the
selection in the dropdownlist and click the go button (on the web page), the
reportviewer doesn't refresh.

What i have done so far is i have the go button coded to do a select on the
objectdatasource like ObjectDataSource1.Select(). I assign the parameter
values in the Objectdatasource selecting event. This one calls the Function i
have in the business object but the retrieve of the report viewer shows the
same data. I even issued the ReportViewer.DataBind() in the Object datasource
selected event. What am i doing wrong?
 
M

Mike MacMillan

Houston,
a) what event are you doing your databinding in(OnInit, OnLoad,
etc...)?
b) can you post a little code?

thanks,
Mike MacMillan
 
H

Houston Lucifer

In the Page Load Event
If Not isPostBack() Then
ddlApproval.DataBind()
End If

In the page markup
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana" Font-Size="8pt"
Height="400px" Width="100%">
<LocalReport ReportPath="ItemStatusReport.rdlc"
DisplayName="Item Status">
<DataSources>
<rsweb:ReportDataSource
DataSourceId="ObjectDataSource1" Name="ItemStatusDS_ApprovalTable" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetItemsDenied"
TypeName="ReportClass">
<SelectParameters>
<asp:ControlParameter ControlID="ddlApproval"
DefaultValue="D" Name="approvalFlag"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

As soon as the page loads it picks up the first value in the dropdown and
retrieves the report, but when i change the value in the dropdown
(autopostback = yes) the report does not refresh. I called the
ObjectDataSource.Select method in the DDL selectedindexchanged event it
didn't help. I am wasting lot of time figuring out which is hopefully a
simple problem.
 
M

Mike MacMillan

Houston,
i don't see the code for the dropdown in the snippet you provided, is
this control created dynamically, or does the rsweb:ReportViewer
control create a dropdownlist? you are basically changing the report
based on the selected item in the dropdownlist correct? is the
dropdownlist populated upon postback (ie, are you sure viewstate is
working correctly?).

Mike MacMillan
 
H

Houston Lucifer

Dropdown was being populated by a function using the markup
<%# GetApprovalCodes() %> DataTextField="descr" DataValueField="code">

Yes, you are correct about the dropdown. I change the report based on the
value on the dropdown.

I think i had some serious problems with the view state. What i did now was
set the enable autopost back of the Dropdown to false and added a go button
on the web page. In the go button click event, i call the
objectdatsource1.Select method and then i issued
ReportViewer1.LocalReport.Refresh() command and it fixed it.

Thanks very much for your help. I appreciate it.
 
T

thejez

you shouldnt need the objectdatasource.select ... the
ReportViewer1.LocalReport.Refresh() is all you need to do. I am doing the
same thing you are but all i did was call refresh and it works fine.

I would like to stop the "auto-load" behaviour of the report though. I dont
like the report running when the page first loads... still havent figured
that out.
 

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,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top