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

If previous row value same don't display

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gordon
Top achievements
Rank 1
Gordon asked on 23 Mar 2009, 10:23 AM
Is there a way to not display a cell value if the previous row has the same value for this cell like so

Paris         18/12/08
                  21/12/08
London     19/12/08

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2009, 12:44 PM
Hello Gordon,

You can try out the following code to achieve your scenario:
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            int index = dataItem.ItemIndex;                         
                if (index > 0) 
                { 
                    if (dataItem["ColumnUniqueName"].Text == RadGrid1.Items[index - 1].Cells[1].Text) 
                        dataItem["ColumnUniqueName"].Text = " "
                }            
        } 
    } 

Thanks
Princy.
0
Gordon
Top achievements
Rank 1
answered on 23 Mar 2009, 02:21 PM
Excellent needs a slight change to remember the last value but basically worked like a dream
    Dim mTourDepDate As String = "~~~~" 
 
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound  
        If e.Item.ItemType = GridItemType.Item Or e.Item.ItemType = GridItemType.AlternatingItem Then  
            Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)  
            Dim index As Integer = dataItem.ItemIndex  
 
            If dataItem("TourDepDate").Text = mTourDepDate Then  
                dataItem("TourDepDate").Text = " " 
            Else  
                mTourDepDate = dataItem("TourDepDate").Text  
            End If  
        End If  
    End Sub  
 


Tags
Grid
Asked by
Gordon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Gordon
Top achievements
Rank 1
Share this question
or