locked
Report Viewer and Sql Datasource RRS feed

  • Question

  • User-1158855013 posted

    Hi,


    I can't seem to filter the records using filter expressions in ReportViewer. I'm able to list all the records but when it comes to filter its not doing anything here is my code below. Any help will greatly be appreciated

      Search By Case number: <asp:TextBox ID="txtcaseno" runat="server"></asp:TextBox> 
       <asp:Button ID="btncase" runat="server" Text="Search" />
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
        WaitMessageFont-Names="Verdana" Width="900px" Height="600px" 
            PageCountMode="Actual">
        <LocalReport ReportPath="Admin\Cases.rdlc">
            <DataSources>
                <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="DataSet1" />
            </DataSources>
        </LocalReport>
    </rsweb:ReportViewer>
    
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            
            SelectCommand="SELECT AYFS.CaseNumber, Clients2.firstName, Clients2.lastName, AYFS.DFC, AYFS.DFCPhone, AYFS.Recvd, AYFS.Expires, AYFS.DateClosed, AYFS.Closed, AYFS.Outcome FROM AYFS INNER JOIN Clients2 ON AYFS.ClientId = Clients2.clientID">
                 
        </asp:SqlDataSource>


     Protected Sub btncase_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncase.Click
    
            Dim tsql As String
    
            tsql = "CaseNumber=" & Me.txtcaseno.Text & ""
    
            Me.SqlDataSource1.FilterExpression = tsql
            Me.SqlDataSource1.DataBind()
            'ReportViewer1.LocalReport.
            ReportViewer1.DataBind()
    
        
    
        End Sub



    Thursday, January 6, 2011 11:27 AM

Answers

  • User-2110079211 posted

    why dont you use it at design time like this 


     <asp:SqlDataSource
                    id="SqlDataSource1"
                    runat="server"
                    ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
                    SelectCommand="SELECT AYFS.CaseNumber, Clients2.firstName, Clients2.lastName, AYFS.DFC, AYFS.DFCPhone, AYFS.Recvd, AYFS.Expires, AYFS.DateClosed, AYFS.Closed, AYFS.Outcome FROM AYFS INNER JOIN Clients2 ON AYFS.ClientId = Clients2.clientID"
                    FilterExpression="CaseNumber='{0}'">
                    <FilterParameters>
                        <asp:ControlParameter Name="CaseNumber" ControlId="txtcaseno" PropertyName="Text"/>
    </FilterParameters> </asp:SqlDataSource>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 6, 2011 12:39 PM