locked
RDLC Reporting with DataSets on Visual Studio 2010 RRS feed

  • Question

  • User51715618 posted

    Hello,

    I have Report.rdlc file and different Placeholders on it.

    I also have a couple datasets with a table on each of it. The table structure is like following

    ID Name
    --  -----
    1   John
    2   Michael
    3  Robert

    I am trying to bind these names to diffent place holders.
    But place holder always uses the first row.

    =First(Fields!Name.Value, "DataSetPatientInfo")

    Is there way to say display the name of the row which has the id of 2?

    I need a condition but whenever I write an IIF condition , it is checking the condition on the first row.

    I need something like following

    IIF(Fields!ID.Value = 2, (Fields!Name.Value, "DataSetPatientInfo"), "")

    or I need a search/filter condition.

    If I remove the First keyword, it gives an error saying  "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope"

    Any help will be appreciated.

    Wednesday, August 22, 2012 4:46 PM

Answers

  • User1619792777 posted

    Hi,

    You will have to replace the textbox with Table otherwise your required condition will not work, and in table remove the row details (right click on the row and select delete rows) and have only the header row, now you will have one row with three columns, in the table remove the two columns(delete it) and now you have only one row and one column in the table which looks like a Textbox. Right click table and select the required Dataset Name

    Now in the table click properties and select Filter

    Table --> Right Click -->Tablix properties -->Filter -->Add

    Now in the expression select ID and in the value provide the value as 2. Now it will work as you expected.

    This should work for you, Please let me know if you have any problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 29, 2012 7:05 AM

All replies

  • User1619792777 posted

    Hi C.Avci

    You can do like this (just copy paste the below expression code to your expression field)

    =First(iif(Fields!ID.Value = 2,Fields!Name.Value,"empty value here"), "DataSetPatientInfo")

    and it will work

    You dont need to include the "First" if you are using "Table" design to bind the dataset, for Textbox "First" is needed along with the dataset name.

    Please let me know if this doesn't works.

    Monday, August 27, 2012 5:49 AM
  • User51715618 posted

    Hi Sivakumar,

    It still does not work. It applies the if statement to the first row of the table. Since ID is 1 in the first of, iif statement renders as "Empty Value Here".

    It does not scan all rows and find the right ID with = 2.

    How can I retrieve the row by ID?

    Thank you

    Monday, August 27, 2012 12:52 PM
  • User1619792777 posted

    Hi,

      You will have to put your expression in table(i think you are using table) and then there is no need to use FIRST, the expression should goes in the first row and desired column of the table like:

    Make sure you had assigned the DatasetName for the table (table->properties->DatasetName)

      =IIF(Fields!ID.Value = 2,Fields!Name.Value,"empty")

    hope this works

    Thanks

    Siva

    Tuesday, August 28, 2012 1:47 AM
  • User51715618 posted

    I am not using a table on the report design.

    On rdls design;
    1. I create a TextBox
    2. Inside of textbox, I right click the mouse and select "Create Placeholder"

    And I am setting this placeholder's value. Value is coming from a data table but as i said it only manipulates the first row of the table.

    If I don't use First, I get the following error.

    Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.

    I have 8 records in my table and I can create 8 datasets with each have 1 row only and accomplish the task but this does not look logical.

    If you are not very busy, can you please just create 1 little application and email me?So that I can compare yours to mine.

    Thank you very much

    Tuesday, August 28, 2012 8:31 PM
  • User1619792777 posted

    Hi,

    You will have to replace the textbox with Table otherwise your required condition will not work, and in table remove the row details (right click on the row and select delete rows) and have only the header row, now you will have one row with three columns, in the table remove the two columns(delete it) and now you have only one row and one column in the table which looks like a Textbox. Right click table and select the required Dataset Name

    Now in the table click properties and select Filter

    Table --> Right Click -->Tablix properties -->Filter -->Add

    Now in the expression select ID and in the value provide the value as 2. Now it will work as you expected.

    This should work for you, Please let me know if you have any problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 29, 2012 7:05 AM