How to pass array to rdlc report?

Joe Yan

I provided a radcombobox to let user select one or more than one department to generate a report (developed by asp.net report (RDLC)).

I had developeded the following dataset:

SELECT     c.DeptID, c.Department, b.Course_Name, b.Course_ID, b.Type, b.Ref_Code, b.Exam
FROM         dbo.db_Competency_List AS a INNER JOIN
                      dbo.db_Course AS b ON a.Course_ID = b.Course_ID INNER JOIN
                      dbo.db_Department AS c ON a.Dept_ID = c.DeptID
where a.Dept_ID in (@Para_DID)

enter image description here

enter image description here

It works if user select one department only.

but if user select more than one department, it seems that the dataset cannot get the parameter. e.g. 12,33,65,78...

Code:

    <telerik:RadComboBox ID="rcb_select_dept" runat="server"  DataSourceID="LDS_ddl_dept" DataTextField="Department" AutoPostBack="True" 
           DefaultMessage="Please Select" DataValueField="DeptID" Width="300" CheckBoxes="true" 
           AllowCustomText="true" >
    </telerik:RadComboBox>
       <asp:LinqDataSource ID="LDS_ddl_dept" runat="server" 
           ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Departments" OrderBy="Department">
       </asp:LinqDataSource>
       </td>
   </tr>
   </table>

   <br />

   <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="1200px" 
                       Height="800px" Font-Names="Verdana" Font-Size="8pt" 
                       InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" 
                       WaitMessageFont-Size="14pt">
                       <LocalReport ReportPath="Reports\template\RequiredByDepartment.rdlc">
                         <DataSources>
                              <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" 
                                    Name="DS_Content" />           
                              </DataSources>
                       </LocalReport>
                   </rsweb:ReportViewer>
<br />

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
    TypeName="LRDBDataSetTableAdapters.vReqByDeptTableAdapter">
    <SelectParameters>
                <asp:Parameter DefaultValue="0" Name="Para_DID" Type="String" />                        
    </SelectParameters>
</asp:ObjectDataSource>

Code behind:

Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
    If e.Item.Value = "Generate" Then

        'Get DID
        Dim strCOM_cmb As String = ""

        For i = 0 To rcb_select_dept.CheckedItems.Count - 1
            If rcb_select_dept.CheckedItems(i).Checked = True Then
                strCOM_cmb += rcb_select_dept.CheckedItems(i).Value.ToString & ","
            End If
        Next
        If Left(strCOM_cmb, 1) = "," Then
            strCOM_cmb = Right(strCOM_cmb, Len(strCOM_cmb) - 1)
        End If
        If Right(strCOM_cmb, 1) = "," Then
            strCOM_cmb = Left(strCOM_cmb, Len(strCOM_cmb) - 1)
        End If
        strCOM_cmb = TrimList(strCOM_cmb)

        Dim params(0) As Microsoft.Reporting.WebForms.ReportParameter
        params(0) = New Microsoft.Reporting.WebForms.ReportParameter("Para_DID", strCOM_cmb)
        ReportViewer1.LocalReport.SetParameters(params)

        ObjectDataSource1.SelectParameters("Para_DID").DefaultValue = strCOM_cmb
        ObjectDataSource1.DataBind()

        Preview()
    End If
End Sub

Sub Preview()

    ReportViewer1.Visible = True
    ReportViewer1.LocalReport.Refresh()

End Sub

How can i pass the department ID array (parameter) to the report ?

thanks.

Alice

I would suggest you to handle this issue in SQL implementation. Just the optional.

To pass text parameter and hope it works as a list, you should represent them in table, after then join your query result to that list in the table. See code below:

Create new table variable and insert each member in the list into the table:

DECLARE @SelectedDeptIds table
(
    DeptID int
)

DECLARE @deptIdTemp varchar(10), @Pos int

SET @Para_DID = LTRIM(RTRIM(@Para_DID))+ ','
SET @Pos = CHARINDEX(',', @Para_DID, 1)

IF REPLACE(@Para_DID, ',', '') <> ''
BEGIN
        WHILE @Pos > 0
    BEGIN
        SET @deptIdTemp = LTRIM(RTRIM(LEFT(@Para_DID, @Pos - 1)))
        IF @deptIdTemp <> ''
        BEGIN
            INSERT INTO @SelectedDeptIds (DeptID) VALUES (CAST(@deptIdTemp AS int))
        END
        SET @Para_DID = RIGHT(@Para_DID, LEN(@Para_DID) - @Pos)
        SET @Pos = CHARINDEX(',', @Para_DID, 1)
    END
END 

Next code is to join table to the list:

SELECT     c.DeptID, c.Department, b.Course_Name, b.Course_ID, b.Type, b.Ref_Code, b.Exam
FROM       dbo.db_Competency_List AS a INNER JOIN
           dbo.db_Course AS b ON a.Course_ID = b.Course_ID INNER JOIN
           dbo.db_Department AS c ON a.Dept_ID = c.DeptID
INNER JOIN @SelectedDeptIds d ON a.Dept_ID = d.DeptID 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to pass array to rdlc report?

From Dev

Report Viewer .rdlc How to pass a parameter?

From Dev

WPF RDLC Report and pass parameters

From Dev

Pass Perameter from textbox to RDLC report

From Dev

How to print a .rdlc (SSRS) report as duplex mode?

From Dev

How to Replace Datagridview value in Rdlc Report

From Dev

How to show 4000 characters in RDLC report

From Dev

How to get desired output in row RDLC report

From Dev

How to make RDLC report two column

From Dev

RDLC Report - how to dynamically set the height of Tablix?

From Dev

How to change color of a column in RDLC report?

From Dev

How to show 4000 characters in RDLC report

From Dev

How to have different type of variable in report(.rdlc)

From Dev

How to See the XML behind the Report (RDLC)

From Dev

RDLC Report: Apply Filter to Report

From Dev

How can you use Linq result with RDLC report?

From Dev

How to set line height to text box in RDLC report?

From Dev

How to get specific row from Dataset in RDLC report

From Dev

How to remove some data in Header in next page (RDLC Report)

From Dev

How to use multiple datasets in rdlc c# report

From Dev

RDLC Report - How to calculate Total Hours from Time in Hours:Minutes

From Dev

How to directly print rdlc report without showing PrintDialog() in C#?

From Dev

How to set reportdatasource to rdlc report in vb.net?

From Dev

How can you use Linq result with RDLC report?

From Dev

How to create a dynamic query in a local report(.rdlc) in c#

From Dev

How to add a watermark to my RDLC report programmatically under some condition?

From Dev

How to change the background color of a row in RDLC report on mouse over?

From Dev

How to show a text box if value in tablix is empty in RDLC report

From Dev

How to add the group of cells with the same structure in RDLC report?

Related Related

  1. 1

    How to pass array to rdlc report?

  2. 2

    Report Viewer .rdlc How to pass a parameter?

  3. 3

    WPF RDLC Report and pass parameters

  4. 4

    Pass Perameter from textbox to RDLC report

  5. 5

    How to print a .rdlc (SSRS) report as duplex mode?

  6. 6

    How to Replace Datagridview value in Rdlc Report

  7. 7

    How to show 4000 characters in RDLC report

  8. 8

    How to get desired output in row RDLC report

  9. 9

    How to make RDLC report two column

  10. 10

    RDLC Report - how to dynamically set the height of Tablix?

  11. 11

    How to change color of a column in RDLC report?

  12. 12

    How to show 4000 characters in RDLC report

  13. 13

    How to have different type of variable in report(.rdlc)

  14. 14

    How to See the XML behind the Report (RDLC)

  15. 15

    RDLC Report: Apply Filter to Report

  16. 16

    How can you use Linq result with RDLC report?

  17. 17

    How to set line height to text box in RDLC report?

  18. 18

    How to get specific row from Dataset in RDLC report

  19. 19

    How to remove some data in Header in next page (RDLC Report)

  20. 20

    How to use multiple datasets in rdlc c# report

  21. 21

    RDLC Report - How to calculate Total Hours from Time in Hours:Minutes

  22. 22

    How to directly print rdlc report without showing PrintDialog() in C#?

  23. 23

    How to set reportdatasource to rdlc report in vb.net?

  24. 24

    How can you use Linq result with RDLC report?

  25. 25

    How to create a dynamic query in a local report(.rdlc) in c#

  26. 26

    How to add a watermark to my RDLC report programmatically under some condition?

  27. 27

    How to change the background color of a row in RDLC report on mouse over?

  28. 28

    How to show a text box if value in tablix is empty in RDLC report

  29. 29

    How to add the group of cells with the same structure in RDLC report?

HotTag

Archive