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

Assign DataTable column to a TextBox

1 Answer 228 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
VanirDev
Top achievements
Rank 1
VanirDev asked on 03 Jun 2009, 10:45 PM
Hi,
I have a trouble displaying a value in a TextBox.
I found simmilar post but unfortunately the link for it is broken (http://www.telerik.com/community/forums/reporting/telerik-reporting/assigning-datatable-column-to-textbox.aspx)

 Here is my setup:

On a web form I do the following:
BusinessObjects.ProjectStatementReportCollection collection = new BusinessObjects.ProjectStatementReportCollection(); 
collection.Query.Where(collection.Query.ProjectStatementReportId == projectStatementReportId); 
DataTable dt = collection.Query.LoadDataTable(); 
ProjectStatementReport report1 = new ProjectStatementReport(); 
report1.DataSource = dt
ReportViewer1.Report = report1
BusinessObjects is a EntitySpaces's object.

In the report designer in the detail section (on panel, list control) I have a TextBox with its value set to "=Construction_Mgmt_In".
This text box's value is not being displayed.
However in ItemDataBound for the detail item I can assign textbox's value in the following way.
private void detail_ItemDataBound(object sender, EventArgs e) 
      Telerik.Reporting.Processing.DetailSection section = (Telerik.Reporting.Processing.DetailSection)sender; 
      System.Data.DataRow row = (System.Data.DataRow)section.DataObject.RawData; 
      Telerik.Reporting.Processing.TextBox procTextbox = (Telerik.Reporting.Processing.TextBox)section.ChildElements.Find("textBox2", true)[0]; 
      procTextbox.Value = row["Construction_Mgmt_In"].ToString(); 
 

I would like to be able to specify TextBox value in the designer rather than through item's ItemDataBound event.
Also do you know how to set up EntitySpaces' esDataSource as a DataSource for the report?

Thank you,
Pawel Mozdzen

1 Answer, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 08 Jun 2009, 01:21 PM
Hi Pawel,

If I have understood your report layout correctly, you have the "textBox2" item residing in a List item. The List item (that is based on the Table item) consumes the data from its data source (set through its DataSource property) and not from the Report's data source. On the other hand, from the code snippet  I can tell that you are setting a data source for the report and not for the List item and this is the reason for the incorrect output.

The List item represents a simple data repeater item that repeats its content for each row of the data source. This is very similar to a report with detail section only. So you have two options - use a report with detail section and place all items inside it; or use an unbound report with a List item (inside the detail section for example) with a valid data source.

The programmatic approach with ProcessingElement.ElementCollection.Find() works because of the 2nd parameter set to True that means to look for all child elements down the hierarchy with the given name (False means to look only for the direct children with this name). So the Find() method will return the proper "textBox2" item.

 
Sincerely yours,
Svetoslav
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.
Tags
General Discussions
Asked by
VanirDev
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Share this question
or