I'm new to telerik, i have a method which return a List of associations and its members, i would like to display this information in a report, i tired to bind the firstName field value of a member to a textbox and in the report3 design, i assigned the FirstName textbox value to "=Fields.Members[0].FirstName", the method FindAllAssociations return a list of AssociationModel which has a "Members" property (of type list<AssociationModel>) .
So how to set the FirstName textbox value ?
var reportingModule1 = ReportingModule.CreateModule()
Report report =
new
Report3();
var objectDataSource =
new
Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = reportingModule1;objectDataSource.DataMember =
"FindAllAssociations";
report.DataSource = objectDataSource;And thank you in advance.
12 Answers, 1 is accepted
Our suggestion is to nest data items (Report, Table, Crosstab, List or Chart) as elaborated:
- bind the report to the objects array with ObjectDataSource component;
- use bindings to bind the nested data item DataSource property directly to =ReportItem.Members;
- set the nested data item (Table/List/Crosstab) Textbox.Value to =Fields.FirstName expression.
Peter
the Telerik team
Thank you for the help, i tried to follow the sample example, but it didn't work for me, an exception message occur in the report "An error has occured while processing Table 'Level1List': Exception has been thrown by the target of an invocation.
--------------InnerException----------------
The specified named connection is either not found in the configuration, not intended to be used with the EntityClientProvider, or not valid."
this is my code
namespace
Telerik.Reporting.Examples.CSharp.NewFolder1
{
partial
class
ReportNested
{
#region Component Designer generated code
/// <summary>
/// Required method for telerik Reporting designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent()
{
Telerik.Reporting.TableGroup tableGroup3 =
new
Telerik.Reporting.TableGroup();
Telerik.Reporting.TableGroup tableGroup4 =
new
Telerik.Reporting.TableGroup();
Telerik.Reporting.TableGroup tableGroup1 =
new
Telerik.Reporting.TableGroup();
Telerik.Reporting.TableGroup tableGroup2 =
new
Telerik.Reporting.TableGroup();
this
.detail =
new
Telerik.Reporting.DetailSection();
this
.Level1List =
new
Telerik.Reporting.List();
this
.panel1 =
new
Telerik.Reporting.Panel();
this
.Level1Name =
new
Telerik.Reporting.TextBox();
this
.Level2List =
new
Telerik.Reporting.List();
this
.panel2 =
new
Telerik.Reporting.Panel();
this
.Level2Name =
new
Telerik.Reporting.TextBox();
this
.objectDataSource1 =
new
Telerik.Reporting.ObjectDataSource();
this
.panel3 =
new
Telerik.Reporting.Panel();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
//
// detail
//
this
.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(2.1812498569488525D);
this
.detail.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.Level1List});
this
.detail.Name =
"detail"
;
//
// Level1List
//
this
.Level1List.Body.Columns.Add(
new
Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Inch(4.3020834922790527D)));
this
.Level1List.Body.Rows.Add(
new
Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Inch(1.9812499284744263D)));
this
.Level1List.Body.SetCellContent(0, 0,
this
.panel1);
tableGroup3.Name =
"ColumnGroup1"
;
this
.Level1List.ColumnGroups.Add(tableGroup3);
this
.Level1List.DataSource =
this
.objectDataSource1;
this
.Level1List.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.panel1});
this
.Level1List.Location =
new
Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.40000000596046448D), Telerik.Reporting.Drawing.Unit.Inch(0.19999997317790985D));
this
.Level1List.Name =
"Level1List"
;
tableGroup4.Groupings.AddRange(
new
Telerik.Reporting.Data.Grouping[] {
new
Telerik.Reporting.Data.Grouping(
""
)});
tableGroup4.Name =
"RowGroup1"
;
this
.Level1List.RowGroups.Add(tableGroup4);
this
.Level1List.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.3020834922790527D), Telerik.Reporting.Drawing.Unit.Inch(1.9812499284744263D));
//
// panel1
//
this
.panel1.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.Level1Name,
this
.Level2List});
this
.panel1.Name =
"panel1"
;
this
.panel1.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.3020834922790527D), Telerik.Reporting.Drawing.Unit.Inch(1.9812499284744263D));
this
.panel1.Style.BackgroundColor = System.Drawing.Color.FromArgb(((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(192)))), ((
int
)(((
byte
)(192)))));
this
.panel1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid;
this
.panel1.Style.BorderWidth.Default = Telerik.Reporting.Drawing.Unit.Pixel(1D);
//
// Level1Name
//
this
.Level1Name.Location =
new
Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.099999986588954926D), Telerik.Reporting.Drawing.Unit.Inch(0.058333396911621094D));
this
.Level1Name.Name =
"Level1Name"
;
this
.Level1Name.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.3000000715255737D), Telerik.Reporting.Drawing.Unit.Inch(0.20000004768371582D));
this
.Level1Name.Style.BackgroundColor = System.Drawing.Color.FromArgb(((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(192)))));
this
.Level1Name.Value =
"=Fields.Name"
;
//
// Level2List
//
this
.Level2List.Bindings.Add(
new
Telerik.Reporting.Binding(
"DataSource"
,
"= Fields.Members"
));
this
.Level2List.Body.Columns.Add(
new
Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Inch(4.0104165077209473D)));
this
.Level2List.Body.Rows.Add(
new
Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Inch(1.3375787734985352D)));
this
.Level2List.Body.SetCellContent(0, 0,
this
.panel2);
tableGroup1.Name =
"ColumnGroup1"
;
this
.Level2List.ColumnGroups.Add(tableGroup1);
this
.Level2List.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.panel2});
this
.Level2List.Location =
new
Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.099999986588954926D), Telerik.Reporting.Drawing.Unit.Inch(0.30000010132789612D));
this
.Level2List.Name =
"Level2List"
;
tableGroup2.Groupings.AddRange(
new
Telerik.Reporting.Data.Grouping[] {
new
Telerik.Reporting.Data.Grouping(
""
)});
tableGroup2.Name =
"RowGroup1"
;
this
.Level2List.RowGroups.Add(tableGroup2);
this
.Level2List.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.0104165077209473D), Telerik.Reporting.Drawing.Unit.Inch(1.3375787734985352D));
//
// panel2
//
this
.panel2.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.Level2Name});
this
.panel2.Name =
"panel2"
;
this
.panel2.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.0104165077209473D), Telerik.Reporting.Drawing.Unit.Inch(1.3375787734985352D));
this
.panel2.Style.BackgroundColor = System.Drawing.Color.FromArgb(((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(224)))), ((
int
)(((
byte
)(192)))));
this
.panel2.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid;
this
.panel2.Style.BorderWidth.Default = Telerik.Reporting.Drawing.Unit.Pixel(1D);
//
// Level2Name
//
this
.Level2Name.Location =
new
Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.4000001847743988D), Telerik.Reporting.Drawing.Unit.Inch(0.099921226501464844D));
this
.Level2Name.Name =
"Level2Name"
;
this
.Level2Name.Size =
new
Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(2.1000003814697266D), Telerik.Reporting.Drawing.Unit.Inch(0.20000004768371582D));
this
.Level2Name.Style.BackgroundColor = System.Drawing.Color.FromArgb(((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(255)))), ((
int
)(((
byte
)(192)))));
this
.Level2Name.Value =
"=Fields.FirstName"
;
//
// objectDataSource1
//
this
.objectDataSource1.DataSource =
typeof
(AER.BusinessLayer.Model.AssociationModel);
this
.objectDataSource1.Name =
"objectDataSource1"
;
//
// panel3
//
this
.panel3.Name =
"panel3"
;
//
// ReportNested
//
this
.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.detail});
this
.PageSettings.Landscape =
false
;
this
.PageSettings.Margins.Bottom = Telerik.Reporting.Drawing.Unit.Inch(1D);
this
.PageSettings.Margins.Left = Telerik.Reporting.Drawing.Unit.Inch(1D);
this
.PageSettings.Margins.Right = Telerik.Reporting.Drawing.Unit.Inch(1D);
this
.PageSettings.Margins.Top = Telerik.Reporting.Drawing.Unit.Inch(1D);
this
.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
this
.Style.BackgroundColor = System.Drawing.Color.White;
this
.Width = Telerik.Reporting.Drawing.Unit.Inch(5.6520829200744629D);
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
}
#endregion
// private ObjectDataSource objDatasource = new ObjectDataSource();
private
Telerik.Reporting.DetailSection detail;
private
List Level1List;
private
Panel panel1;
private
TextBox Level1Name;
private
List Level2List;
private
Panel panel2;
private
TextBox Level2Name;
// private List Level3List;
private
Panel panel3;
private
ObjectDataSource objectDataSource1;
}
}
PS: i use Entity framework ORM.
And thank you in advance.
For retrieving data from Entity Framework our suggestion is to use the EntityDataSource Component. The EntityDataSource component enables data items to connect to an ADO.NET Entity Data Model.
Just to note that to use the Report Designer and Report Wizard the Entity Data Model should be located in a separate class library. The connectionString to the database should be copied to the config file of the report class library for the Data Explorer and Preview to work.
Peter
the Telerik team
why my edit expression window doesn't show fields property like in the bottom left side it shows some properties like:Aggregates constatnts, functions , fields, global functions, operaters, reportparameters.
i am using Q2 2012 telerik reporting, my edit expression window doesn't show fields property, i guess that's my textbox values doesn't show up on the report when run the report.
can u give me u r help
thanks in advance
We will need more information:
- Which data source component you utilize?
- In which data item the textbox is located - report, table, crosstab, list, subreport?
- Have you set the data item's Datasource property to a data source component?
- Do you get any errors when you open a data explorer and select the data source component?
Greetings,
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 >
--my textboxes is located in the report detail section(in the detail section i used the panel in panel i used the text boxes).
--if i point the sqldatasource1 it gives the results and bind the data souce results to textboxes but i want set the sql data source based on the in put report parameters that's why i used itemdatabinding event like :
private void FoodAssistanceActiveReview_ItemDataBinding(object sender, EventArgs e)
{
string SQL;
if (this.ReportParameters["vintworkerid"].Value.Equals("-1"))
{ sql = " query";
this.sqldatasource1.selectcommand = sql}
else{
-------
---
}
when i use the itemdatabinding results not bind to textboxes.
when i point the sqldata source it shows the fields no Errors , when i didn't point any data source it shows nothing.
can you help me for my issues ASAp.
thanks in Advance
Siva
We have noticed in the provided code snippet that you had used the Report Parameter definition item (this.ReportParameters["vintworkerid"].Value) instead of the processing counterpart. The definition report parameter value is actually the default value. The sender of the event is always the processing counterpart of the data item and you can use it to access the processing report parameter. For more information check out the Using Report Parameters programmatically.
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 >
it's real wonder , it's act like weird . i use the like this
private void AssistanceActive_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
string SQL;
if (this.ReportParameters["vintworkerid"].Value.Equals("-1"))
{
SQL= "SELECT qcr.get_pending (:vintprg_typ,-1, " +
" TO_DATE (:vstart_date, 'MM/DD/YYYY'), " +
" TO_DATE (:vend_date, 'MM/DD/YYYY') " +
" ) pen_cnt, " ;
this.sqlDataSource1.SelectCommand = SQL;
this.sqlDataSource1.Parameters[0].Value = report.Parameters["vintprgtyp"].Value;
this.sqlDataSource1.Parameters[1].Value = report.Parameters["vstartdate"].Value;
this.sqlDataSource1.Parameters[2].Value = report.Parameters["venddate"].Value;
this.sqlDataSource1.Parameters[3].Value = report.Parameters["vintworkerid"].Value;
SQL = "------";
this.sqlDataSource2.SelectCommand = SQL;
SQL = "-------";
this.sqlDataSource3.SelectCommand = SQL;
}
else
{
if (this.ReportParameters["vrpttype"].Value.Equals("Reviewer"))
{
SQL= "SELECT qcr.get_pending (:vintprg_typ,-1, " +
" TO_DATE (:vstart_date, 'MM/DD/YYYY'), " +
" TO_DATE (:vend_date, 'MM/DD/YYYY') " +
" ) pen_cnt, " ;
this.sqlDataSource1.SelectCommand = SQL;
this.sqlDataSource1.Parameters[0].Value = report.Parameters["vintprgtyp"].Value;
this.sqlDataSource1.Parameters[1].Value = report.Parameters["vstartdate"].Value;
this.sqlDataSource1.Parameters[2].Value = report.Parameters["venddate"].Value;
this.sqlDataSource1.Parameters[3].Value = report.Parameters["vintworkerid"].Value;
SQL = "----- ";
this.sqlDataSource2.SelectCommand = SQL;
SQL = "-------";
this.sqlDataSource3.SelectCommand = SQL;
}
else
{
SQL= "SELECT qcr.get_pending (:vintprg_typ,-1, " +
" TO_DATE (:vstart_date, 'MM/DD/YYYY'), " +
" TO_DATE (:vend_date, 'MM/DD/YYYY') " +
" ) pen_cnt, " ;
this.sqlDataSource1.SelectCommand = SQL;
this.sqlDataSource1.Parameters[0].Value = report.Parameters["vintprgtyp"].Value;
this.sqlDataSource1.Parameters[1].Value = report.Parameters["vstartdate"].Value;
this.sqlDataSource1.Parameters[2].Value = report.Parameters["venddate"].Value;
this.sqlDataSource1.Parameters[3].Value = report.Parameters["vintworkerid"].Value;
SQL = "----- ";
this.sqlDataSource2.SelectCommand = SQL;
SQL = "------ ";
this.sqlDataSource3.SelectCommand = SQL;
}
}
}
}
}
only Sqldatasource1 results not bind to Textboxes, even default values are also not binded, when run the report textbox values showing nothing even default values zero also not showed up. but Sqldatasource2 and 3 results values correctly binded to other textboxes
can you tell me what i did wrong ASAP pleasee Peter.
Thanks in Advance
In you previous post you have stated that all of the textboxes are located in the report's detail. However report data items such as Report,Crosstab/Table/List, Chart and SubReport can be bound to a single data source only. If you have to use multiple DataSources, you can use multiple data Items. For example use List/Table item to directly show data in main report from the second data source component. Just set the data item's DataSource property to the appropriate data source component.
If you still experience difficulties please open a support thread and send us the report definition.
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 >