Hello
I got a Radgrid
I have a textbox within the FormTemplate
and i want to disable the textbox but only in editmode not in insertmode
i use this code:
If e.Item.IsInEditMode Then
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim txt As TextBox = (TryCast(item.FindControl("txt"), TextBox))
txt.Enabled = False
End If
can somebody help me please
thanks
I got a Radgrid
I have a textbox within the FormTemplate
and i want to disable the textbox but only in editmode not in insertmode
i use this code:
If e.Item.IsInEditMode Then
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim txt As TextBox = (TryCast(item.FindControl("txt"), TextBox))
txt.Enabled = False
End If
can somebody help me please
thanks
8 Answers, 1 is accepted
0

Yeroon
Top achievements
Rank 2
answered on 09 Mar 2010, 04:51 PM
Maybe the ItemCommand event works for you:
Use it in the OnItemCommand event of the Grid:
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) |
If e.CommandName = RadGrid.InitInsertCommandName Then |
'enable textbox here |
ElseIf e.CommandName = RadGrid.EditCommandName Then |
'disable textbox here |
End If |
End Sub |
Use it in the OnItemCommand event of the Grid:
OnItemCommand
="RadGrid1_ItemCommand"
0

Luis
Top achievements
Rank 1
answered on 09 Mar 2010, 07:37 PM
thanks
but bring me another problem
how i to find the textbox i want to diseable?
i can find it but in the itemdatabound event
but bring me another problem
how i to find the textbox i want to diseable?
i can find it but in the itemdatabound event
0
Accepted

Princy
Top achievements
Rank 2
answered on 10 Mar 2010, 07:28 AM
Hi,
You can distinguish between the Insert and edit modes in the ItemDataBound/ItemCreated events and enable /disable the textbox accordingly:
Thanks,
Princy
You can distinguish between the Insert and edit modes in the ItemDataBound/ItemCreated events and enable /disable the textbox accordingly:
Private Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then |
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) Dim txt As TextBox = (TryCast(item.FindControl("txt"), TextBox)) |
If e.Item.OwnerTableView.IsItemInserted Then |
txt.Enabled=True |
Else |
txt.Enabled=False |
End If |
End If |
End Sub |
Thanks,
Princy
0

Luis
Top achievements
Rank 1
answered on 10 Mar 2010, 01:30 PM
Thanks a lot :)
0

gc_0620
Top achievements
Rank 1
answered on 25 Jan 2016, 05:30 PM
Hi there, My question is how to conditionally enable/disable all Text Boxes in Edit Form. I have a form with more than 50 Text Boxes.
I can manually enable/disable one by one. Is there any way I can disable them from code such as:
foreach (Control ctrl in item)
{
if (ctrl is TextBox)
((TextBox)ctrl).Enabled = false;
}
if so, which event? Pre_Render or Item_Created or any other event. Thanks
gc_0620
0
Hello,
Generally, if you are using RadTextBoxes, you can access all of them on the page using a similar implementation to the following approach and disable each of them:
Or this can be also achieved on server-side with recursion.
Regards,
Eyup
Telerik
Generally, if you are using RadTextBoxes, you can access all of them on the page using a similar implementation to the following approach and disable each of them:
Copy Code
function
pageLoad() {
var
radControls = $telerik.radControls;
for
(
var
i = 0; i < radControls.length; i++) {
if
(Telerik.Web.UI.RadDatePicker.isInstanceOfType(radControls[i])) {
var
picker = radControls[i];
picker.set_minDate(
new
Date());
}
}
}
Or this can be also achieved on server-side with recursion.
Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0

gc_0620
Top achievements
Rank 1
answered on 28 Jan 2016, 07:31 PM
Hi Eyup,
I can't disable all Texboxes in pageload event. I would like to enable/disable TextBoxes based on user security rights. Ex: Admins are allowed to make changes, viewers can't make any changes. That's why I am using Item Databound event to verify/validate security credentials.
Thanks
gc_0620
0
Hi,
Then you can access the TextBoxes depending on your chosen EditMode and toggle their visibility accordingly:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode
Regards,
Eyup
Telerik
Then you can access the TextBoxes depending on your chosen EditMode and toggle their visibility accordingly:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode
Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items