is it possible to bind a report controls value to an index value like
=Fields.Data[0]
In my report I have a table that is bound to an objectdatasource. I want to bind some of the tables columns to a list of values in the objects using an indexer. Can that be done? I haven't found a way so far.
Thx
10 Answers, 1 is accepted
In order to handle array values in an expression, our suggestion is to utilize an user function. Check out the following sample:
public
static
string
GetItemValue(
string
[] values,
int
index)
{
return
values[index];
}
Then you can use the following expression:
=GetItemValue(Fields.Data,0) Kind regards,
Peter
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
Please take a look at the The expression contains undefined function call MyUserFunction() error KB article.
Regards,
Stef
Telerik
Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.
My function work fine but Data seem not working.... And I need using fields by index.
This is my expression with my valid function ;
{Rapports.methodesCommunes.GetItemValue(Fields.Data, 1)}
See attachement.
Fields.Data is a field coming from the data source, not a system reserved field. It is used by the original poster in the same way as Fields.SomeField is used in other examples.
Also this thread is about how to use indexers in fields containing objects i.e., Fields.SomeField[1]. If I understand correctly, you are trying to use indexer with the Fields collection itself i.e., Fields[1], which is another matter and is currently not possible.
Regards,
Nasko
Telerik
New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.
Thank you for the answer.
Exactly, I need to get the value of the first field without using the name of the field.
It's possible to get in C# in the event DataBound of the textbox (with a dataset or else)?
Indeed it is possible to access the data objects of a processing item in an event using the ProcessingElement.DataObject Property, but you will still be required to pass the name of the desired field as an indexer value. Thus, you cannot get the value of the first field without using the name of the field.
Still if you need additional assistance please elaborate further on your data schema model and scenario.
Regards,
Nasko
Telerik
New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.
I have a report where the datasource has a firstname and lastname field. I want to bind the title to use the firstname and lastname from the first record in the datasource. To do added the following function to the report code:
public static string GetItemValue(string[] values, int index)
{
return values[index];
}
And set the title textbox value to:
= GetItemValue(Fields.FirstName,0) + " " + GetItemValue(Fields.LastName,0)
But I get the following error:
Type mismatch in function arguments.Cannot find an overload of the function GetItemValue that accepts arguments of type (String, Int32).
Can you tell me how I would correct this.
This error occurs as the function GetItemValue() accepts array of strings as a first parameter (not ). When you pass Fields.FirstName which is of type string as a parameter for this function, the exception is thrown.
To get the first record from the data source you can use First() aggregate function, for example:
= First(Fields.FirstName) + " " + First(Fields.LastName)
Regards,
Katia
Telerik by Progress