Reading Hashtable in Report

3 posts, 0 answers
  1. Prasant
    Prasant avatar
    2 posts
    Member since:
    Jan 2012

    Posted 26 Feb 2013 Link to this post

    I want to show the Hashtable data in textbox of Telerik report. My class structure is like:

    Public class MyClass
    public Hashtable ValHash { get; set; }

    MyClass obj = new MyClass();
    obj.ValHash = new Hashtable();
    obj.ValHash.Add("Name", "Prasant");

    While setting Hahtable value to textbox, as:
    this.textBox1.Value = "= Fields.ValHash[\"Name\"]";

    I am getting an error as "Missing operator before '["Name"]' operand.

    Am i doing anything wrong?
  2. Stef
    Stef avatar
    2920 posts

    Posted 01 Mar 2013 Link to this post

    Hi Prasant,

    Our expression engine does not support indexers, and that is how the values in a Hashtable are accessed, using an an indexer by Key. We can suggest you two approaches:
    • Flatten your data in a DataTable object, e.g. the Key is a Column, and the Value is the value for that column, then you can bind the TextBox item to the field with the corresponding column name;
    • Have user-defined function to get a value by key from the Hashtable as illustrated in the attached sample. The function is used as an expression for the TextBox item Value property, where we pass the Hashtable object field and the searched key;

    I hope this helps.

    the Telerik team

    See what's new in Telerik Reporting Q1 2013. Register for the March 4 webinar to witness the impressive new visualizations in Telerik Reporting. Just for fun, 10 webinar attendees will be randomly selected to win a Telerik T-shirt and a $50 Gift Certificate to ThinkGeek. Register now! Seats are limited!

  3. DevCraft R3 2016 release webinar banner
  4. Prasant
    Prasant avatar
    2 posts
    Member since:
    Jan 2012

    Posted 05 Mar 2013 Link to this post

    Hi Stef,
    Thanks for your response. I would prefer 2nd option suggested by you.
Back to Top