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

Find Control Issue

8 Answers 69 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 27 Jun 2012, 06:41 AM
Hi all,

 i have an issue with my tree list.. i need to find controls  "OnEditCommand" event in my rad tree list ... 

please help ..


Regards,

Prassin

8 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 28 Jun 2012, 07:43 AM
Hi Prassin,

If you have a custom edit form template with controls of your own, just use e.Item.FindControl("IDofYourControl"). If you are using the built-in edit forms, then you can use the Extract values method to get any of the field values in the edit form:

Hashtable newValues = new Hashtable();
((TreeListEditableItem)e.Item).ExtractValues(newValues);

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 07:52 AM
Hi Tsvetoslav,

I have tried this code.. i can get the value from a particular control.. but my wish is not that..  i need to find a control and wish to assign the control "ReadOnly" state or "Disabled " in my tree list .. that is my requirement... please help..


Regards,

Prassin
0
Tsvetoslav
Telerik team
answered on 28 Jun 2012, 09:20 AM
Hello Prassin,

Could you paste your code (aspx and code-behind) using the CODE FORMATTER tool of the ticket editor.

Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 09:33 AM

<asp:TextBox ID=
"txtBoxcode" Text='<%# Bind("SubCatCode") %>' runat="server" Height="8Pt"
    Style="text-transform: uppercase" MaxLength="4">
 </asp:TextBox>

Protected Sub RadTreeList1_EditCommand(ByVal sender As Object, ByVal e As TreeListCommandEventArgs)
       Dim item As TreeListDataItem = TryCast(e.Item, TreeListDataItem)
       Dim txt As TextBox = TryCast(item.FindControl("txtBoxcode"), TextBox)
       txt.Enabled = False
   End Sub


0
Tsvetoslav
Telerik team
answered on 28 Jun 2012, 10:06 AM
Hi Prassin,

Just do it in the ItemDataBound event as follows:

Protected Sub RadTreeList1_ItemDataBound(sender As Object, e As TreeListItemDataBoundEventArgs)
    If TypeOf e.Item Is TreeListEditFormItem AndAlso DirectCast(e.Item, TreeListEditFormItem).IsInEditMode Then
        Dim item As TreeListEditableItem = TryCast(e.Item, TreeListEditableItem)
  
        Dim textBox = TryCast(item.FindControl("txtDiscount"), TextBox)
  
        textBox.Enabled = False
    End If
End Sub

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 10:16 AM
Hi..

Thanks soo much.. its working fine.. and one more thing ... i wish to enable that textbox while click add parent item... edit time need to disable too...


0
Tsvetoslav
Telerik team
answered on 28 Jun 2012, 10:25 AM
Hi Prassin,

Then, the following code snippet should prove helpful:

Protected Sub RadTreeList1_ItemDataBound(sender As Object, e As TreeListItemDataBoundEventArgs)
    If TypeOf e.Item Is TreeListEditFormInsertItem Then
        Dim item As TreeListEditFormInsertItem = TryCast(e.Item, TreeListEditFormInsertItem)
  
        Dim textBox = TryCast(item.FindControl("txtDiscount"), TextBox)
  
        textBox.Enabled = True
    ElseIf TypeOf e.Item Is TreeListEditFormItem AndAlso DirectCast(e.Item, TreeListEditFormItem).IsInEditMode Then
        Dim item As TreeListEditableItem = TryCast(e.Item, TreeListEditableItem)
  
        Dim textBox = TryCast(item.FindControl("txtDiscount"), TextBox)
  
        textBox.Enabled = False
    End If
End Sub



Kind regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prassin
Top achievements
Rank 1
answered on 28 Jun 2012, 11:51 AM
Hi Tsvetoslav,

Thanks soo much for your help...


Regards,

Prassin 
Tags
TreeList
Asked by
Prassin
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Prassin
Top achievements
Rank 1
Share this question
or