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

[Solved] Get Value from a Control in RadGrid

2 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dany V
Top achievements
Rank 1
Dany V asked on 10 Jun 2009, 09:17 PM
Hi, I'm working with a RadGrid on a web application, and I'm usin the EditFormSettings to customize the Edit Form in my grid, inside I have 2 checkboxes and I would like to get the value of that controls so then when CheckBox1 is True, the other one must be False. I used to do this with a formview typing this code:
Dim CheckBox1 As CheckBox = Ctype(FormView.FindControl("CheckBox1"), CheckBox)

but now with this RadGrid I cant get the value, hope anyone could help me

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2009, 04:53 AM
Hi Daniel,

I guess you are using a FormTemplate EditForm with two CheckBoxes. If so you may try the following code snippet to access the CheckBox from the edit form.

ASPX:
 
 <EditFormSettings EditFormType="Template" > 
              <FormTemplate> 
                  <asp:CheckBox ID="CheckBox1" runat="server" /> 
                  <asp:CheckBox ID="CheckBox2" runat="server" /> 
              </FormTemplate> 
            </EditFormSettings> 

VB:
 
 
 
  Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
       If (TypeOf e.Item Is GridEditFormItem) AndAlso (e.Item.IsInEditMode) Then 
            Dim editForm As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) 
           Dim chkbx1 As CheckBox = DirectCast(editForm.FindControl("CheckBox1"), CheckBox) 
            Dim chkbx2 As CheckBox = DirectCast(editForm.FindControl("CheckBox2"), CheckBox) 
            chkbx1.Checked = Not chkbx1.Checked 
            
        End If 
    End Sub 
 
 


Shinu.
0
Dany V
Top achievements
Rank 1
answered on 11 Jun 2009, 05:52 PM
Hi Shinu,

Thanks for the tip, but actually I found another way to do it, but anyway this one help me to solve other problems that I had before.
Thanks again!! :)
Tags
Grid
Asked by
Dany V
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dany V
Top achievements
Rank 1
Share this question
or