Ticket T341662
Visible to All Users

How to loop through all rows in xrtable in XtraReport

created 9 years ago

Hello Devex,

I have an XrTable which is bind from data member in mvc. table has many number of rows.

i want to get the value of one rows in all the rows of a table and get its value and show on to the label.

so how could i get that.
i try

var str1 ="";
foreach (XRTableRow row in this.xrTable5.Rows)
                {
                    foreach (XRTableCell cell in row.Cells)
                    {
                        if (cell.Text == "Cash")
                        {
                           str1 = cell.Text;
                        }
                    }
                }
  str1 = xrTableCell68.Text;

this code on label before_print event but nothing got any success. please suggest the solution for this .

Answers approved by DevExpress Support

created 9 years ago

Hi Sandeep,

It is impossible to obtain all values by iterating through XRTable cells, because our Reporting tools use a different concept. As you know, our report is split to multiple sections (Bands), and each section serves for a different purpose. For example, the DetailBand band type is intended to display values for each data record in your data source. This means that this band is "cloned" for each data source record. Thus, its content is also cloned. As a result, inner XRControls (e.g., XRTable) are also cloned, and their structure remains unchanged. I.e., you get multiple identical single-line XRTables instead of a single XRTable with multiple rows.

Back to your original requirement, I recommend that you handle the BeforePrint event of the required XRTableCell and obtain the cell text there (using the XRTableCell.Text property or XtraReport.GetCurrentColumnValue method). This BeforePrint event will fire for each record, so you will be able to find the required value. Then, handle the XRLabel.PrintOnPage event and customize the XRLabel.Text property based on the previously stored value.

Please try this solution and let me know if you have any difficulties.

See also:
Understanding Report Bands

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.