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

Disable the textboxes when edit button is pressed

1 Answer 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 15 May 2009, 12:20 AM
Hi,
The following code disable the textboxes when "Add a new record" button is pressed.  But i cannot able to disable the textboxes when i press "edit" button. Please write a code for me when "edit" button is pressed.

 Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound 
        If (TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted) Then 
            Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) 
            Dim txtbx1 As TextBox = DirectCast(insertItem("RUYear").Controls(0), TextBox) 
            txtbx1.Text = Year(Now) 
            Dim txtbx2 As TextBox = DirectCast(insertItem("RUMonth").Controls(0), TextBox) 
            txtbx2.Text = Month(Now) 
            txtbx1.Enabled = False 
            txtbx2.Enabled = False 
        End If 
End Sub 

Thanks.

Regards
Syed Arshad

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 15 May 2009, 03:57 AM
Hello Syed,

You can try out the following code to disable the textboxes when edit is clicked:
c#:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) 
 
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then 
        Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
        Dim txtbx1 As TextBox = DirectCast(item("RUYear").Controls(0), TextBox) 
        txtbx1.Text = Year(Now) 
        Dim txtbx2 As TextBox = DirectCast(item("RUMonth").Controls(0), TextBox) 
        txtbx2.Text = Month(Now) 
        txtbx1.Enabled = False 
 
        txtbx2.Enabled = False 
    End If 
End Sub 

Thanks
Princy.
Tags
Grid
Asked by
Syed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or