locked
[ReportViewer 2010] Replace Fields!MyField.Value(0) RRS feed

  • Question

  • Hi all

    In ReportViewer 2005 and also 2008, if we have in DataSource a List<T> (as a DataMember) we can get a specific Item from this List (inside the report) using the syntax (in RDL XML)

     

    <Value>=Fields!MyList.Value(MyIndex)</Value>
    

     

    In ReportViewer 2010, this syntax is no longer work. What Can I do to get a specific Item from my list?

    I Tried to use an External Function GetAt() Like follow

     

    public static class Library
    {
        public static string GetAt(List<String> MyList, int MyIndex)
        {
           return MyList[MyIndex];
        }
    
        //I Also added this function just for test
        public static string Get()
        {
           return "Test String";
        }
        
    }
    

     

    In my report when I Call the function GetAt() like

     

    <Value>=Code.Library.GetAt(Fields!MyList.Value,1)</Value>
    Or 
    <Value>=Code.Library.GetAt(Fields!MyList,1)</Value>
    

    in both case I obtain #Error, but when I call the test function Get(), I obtain the right string.

    I Also tried to change type of MyList to "object" both in DataSource and in Library without success.

     

    Have you any idea??

     

    My DataSource

    public class MyDataSource
    {
      public string MyString {get;set;}
      public List<string> MyList {get;set;}
    }
    

     

    Monday, April 11, 2011 8:23 AM

Answers

  • Upgrading the VS 2010 to SP1 solved my problem

    This is the right syntax

    <Value>=Fields!MyList.Value(MyIndex)</Value>

     

     

    Thancks All

    • Marked as answer by JMEL Becha Wednesday, April 13, 2011 2:39 PM
    Wednesday, April 13, 2011 2:39 PM