This is a migrated thread and some comments may be shown as answers.

array properties on business objects

3 Answers 287 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 24 Jun 2009, 08:15 PM
I am using an object as a data source.  I would like to set a textbox value to an integer in a property that returns an array of integers.  For example, the "DataArray" property on the object returns int[].  I would like to reference "=DataArray[0]" as a textbox value, but I get a "Missing operator before [0] operand" error.  Is there any way to directly utilize an array property of a business object data source?

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 26 Jun 2009, 01:26 PM
Hi Brad,

This is not possible. When you have an array which you want to use as datasource, you should set "=Item" as report item expression i.e.:

 int[] listTypes = new int[3] { 1, 2, 3 };
 this.DataSource = listTypes;

If a report parameter returns an array, you can utilize user functions similar to our Product Line Sales demo report:

 public static string FormatArray(ArrayList array) 
        { 
            StringBuilder sb = new StringBuilder(); 
 
            foreach (object o in array) 
            { 
                if (sb.Length > 1) 
                { 
                    sb.Append(", "); 
                } 
                sb.Append(o.ToString()); 
            } 
            return sb.ToString(); 
        } 
 


Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Steven
Top achievements
Rank 1
answered on 10 Jan 2013, 07:11 PM
If you are binding to objects and your object (POCO or Entity) has an Array Property, you should be able to accomplishing this with a Static User Function, but I don't think this will work with Public Fields.

Value     "= ArrayValue(0, Fields.DataArray)"


public static int ArrayValue(int index, ArrayList array)
{
      if (index > 0 && index < array.Length)
           return array[index];

      return 0; // or pass your default into the function
}


If it says the Function does not exists then I would play around with the array DataType.  
As it is called from a VB Expression I believe the ArrayList type should be correct.
0
Steve
Telerik team
answered on 15 Jan 2013, 01:27 PM
Hello Steven,

If you are unsure of the type of the argument, you can always use object and you would be able to cast to the correct type in the user function, or just figure out the appropriate type and change your user function accordingly.

Greetings,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Steve
Telerik team
Steven
Top achievements
Rank 1
Share this question
or