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

Child Template Colour

2 Answers 20 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shan
Top achievements
Rank 1
Shan asked on 26 Dec 2014, 08:09 AM
I am working with the Rad gridview with Two Child Templates.I want to the Row Formatting  for my ViewTemplates, So I used this Code ,

Private Sub RadGrid_RowFormatting1(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles RadGrid.RowFormatting

        If e.RowElement.ViewTemplate.Parent IsNot Nothing Then
            e.RowElement.ForeColor = Color.Blue
            e.RowElement.BackColor = Color.SkyBlue
        End If

Yes..its working ..Is there any way to give alternative colour to the second child template..I want to differentiate the colour between second template to first template.

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 26 Dec 2014, 09:31 AM
Hi Shan,

Each template has a Caption property, which you can set. Then you can use it in the formatting to determine which template the row is:
Private Sub radGridView1_RowFormatting(sender As Object, e As RowFormattingEventArgs)
    If e.RowElement.ViewTemplate.Caption = "yourTemplate1Captioin" Then
        e.RowElement.ForeColor = Color.Red
    ElseIf e.RowElement.ViewTemplate.Caption = "yourTemplate1Captioin" Then
        e.RowElement.ForeColor = Color.Purple
    Else
        e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    End If
End Sub

Alternatively, you can put some identifier in the Tag property and use it instead.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Shan
Top achievements
Rank 1
answered on 26 Dec 2014, 10:19 AM
Thank You Mr.Stefan...Its working Perfectly . Great Support.
Tags
GridView
Asked by
Shan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Shan
Top achievements
Rank 1
Share this question
or