Current filter:
                                You should refresh the page.
                                Support Center
                                  • Hello Support Team,

                                    I have a simple question about loop through gridview rows.

                                    What i want to achieve is compare row i and row i+1 , and if the specific column is not the same colorize column background.
                                    let me explain using the attachment. The picture shows a simple grid ( -FYI - with LLBLGEN datasource as datasource, it is not directly related to my question!)
                                    let us first compare rows which are first and second ( the first has Id: 2758, the second has Id:2754) ( actually it will done loop using rowcount! or whatever)
                                    if row[0].column[0] != row[1].column[0] then row[0].column[0].Color = "red"
                                    inside a double loop ( outer loop for rows - i , inner loop for columns - j)
                                    if row[i].column[j] != row[i+1].column[j] then row[i].column[j].Color = "red"

                                    How can i achieve this?

                                    Thanks in advance

                                    Please note that
                                    - i cannot use ASPxGridView.GetRowValues , because it requires the column names which i dont know



                                Below, you will find a sample project showing how to color a row based on a certain value. This can be done using within the HtmlRowPrepared event by setting the e.Row.ForeColor property. This event is triggered for every rendered row, so you needn't loop though rows. The ASPxGridView does this itself and generates this event. So, you should determine previous row values in a Page's local variable, and compare these values with the current Row values. To determine row values, use the e.GetValue method in this event handler. It accepts only field names. To determine field names, you may use the following code:

                                List<string> fieldNames = null; protected void ASPxGridView1_HtmlRowPrepared(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e) { if(fieldNames == null) { fieldNames = new List<string>(); for(int i = 0;i < ASPxGridView1.VisibleColumns.Count;i++) if(ASPxGridView1.Columns[i] is DevExpress.Web.ASPxGridView.GridViewDataColumn) fieldNames.Add((ASPxGridView1.Columns[i] as DevExpress.Web.ASPxGridView.GridViewDataColumn).FieldName); } }


                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners