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

Find control in Rad Grid

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 28 Jul 2010, 02:48 PM
Hi All

I need some advice on RAD Grid. I am using edit form template within Rad Grid and within Edit form template I have a panel and a check box. My requirement is I want to enable or disable the panel depending upon the checkbox change. I want to enable the panel when checkbox is selected and disable the panel when checkbox is not seletected.

This is what i am trying to do

    Protected Sub chkEnablePanel(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim chkEnablePanel As CheckBox = CType(sender, CheckBox)
        Dim contactPanel As Panel = CType(RadGridAccContacts.FindControl("Panel1"), Panel)
        If chkEnablePanel.Checked = True Then
            contactPanel.Enabled = True
        Else
            contactPanel.Enabled = False
        End If
    End Sub

<asp:CheckBox ID="chkActivateContact" runat="server" Visible="False" Font-Bold="true"  AutoPostBack="true"
                                        ForeColor="Red" Text="Re-Activate Contact" OnCheckedChanged="chkEnablePanel"  />

Please advice how to find out the child control in edit form template of Rad Grid.

Thanks




2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jul 2010, 06:03 AM
Hello Edward,

In order to get the control in edit form, first access the edit form using NamingContainer property of the CheckBox. Then access the control(Panel) using FindControl method. Check out the following code snippet.

VB.Net:
Protected Sub chkEnablePanel(sender As Object, e As EventArgs)
    Dim chkEnablePanel As CheckBox = DirectCast(sender, CheckBox)
    Dim editItem As GridEditFormItem = DirectCast(chkEnablePanel.NamingContainer, GridEditFormItem)
    Dim contactPanel As Panel = DirectCast(editItem.FindControl("Panel1"), Panel)
    contactPanel.Enabled = chkEnablePanel.Checked
End Sub

Thanks,
Princy.
0
Edward
Top achievements
Rank 1
answered on 29 Jul 2010, 11:43 AM
Thanks Princy
It worked for me.
Tags
Grid
Asked by
Edward
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Edward
Top achievements
Rank 1
Share this question
or