I have a TreeList with an Edit Form Template. How do I go about finding those controls when the edit form is opened? With the RadGrid I could find these controls by using the ItemDataBound event and checking if the item is in edit mode. Is there a similar way to do this with the TreeList control?
Thanks.
Thanks.
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 19 Dec 2011, 06:12 AM
Hello Wiliam,
Try the following code.
C#:
-Shinu.
Try the following code.
C#:
protected void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e){ if (e.Item is TreeListEditableItem && (e.Item as TreeListEditableItem).IsInEditMode) { TreeListEditableItem item = (TreeListEditableItem)e.Item; Label lbl = (Label)item.FindControl("Label1"); }}-Shinu.
0
William
Top achievements
Rank 1
answered on 19 Dec 2011, 03:01 PM
I'm getting a NullReferenceException, it can't seem to find the control. Below is a code snippet:
ASPX
C#
ASPX
<telerik:RadTreeList ID="notificationsTree" runat="server" AutoGenerateColumns="false" AllowSorting="false" AllowPaging="false" OnNeedDataSource="notifications_needdata" DataKeyNames="ID" ParentDataKeyNames="PID" ShowTreeLines="false" EditMode="PopUp" OnLoad="notifications_OnLoad" OnItemDataBound="notificationTree_ItemDataBound"> <Columns> <telerik:TreeListEditCommandColumn ShowEditButton="false" AddRecordText="Add"/> <telerik:TreeListBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID" Visible="false" /> <telerik:TreeListBoundColumn HeaderText="PID" DataField="PID" UniqueName="PID" Visible="false" /> <telerik:TreeListBoundColumn HeaderText="Name" DataField="Name" /> <telerik:TreeListBoundColumn HeaderText="Item" DataField="ItemsID" /> <telerik:TreeListBoundColumn HeaderText="Category" DataField="Category" /> <telerik:TreeListBoundColumn HeaderText="Location" DataField="Location" /> <telerik:TreeListEditCommandColumn ShowAddButton="false" /> </Columns> <EditFormSettings EditFormType="Template" PopUpSettings-Modal="true" InsertCaption="Add Notification" PopUpSettings-Height="200px" PopUpSettings-Width="520px"> <FormTemplate> <table> <tr> <td>Name:</td> <td><telerik:RadTextBox ID="editName" runat="server" EmptyMessage="Enter Name" /></td> <td>Category:</td> <td><telerik:RadComboBox ID="editCategory" runat="server" EmptyMessage="Type a Category" MarkFirstMatch="true" /></td> </tr> <tr> <td>Item:</td> <td><telerik:RadComboBox ID="editItem" runat="server" EmptyMessage="Type a PS#" MarkFirstMatch="true" /></td> <td>Location:</td> <td><asp:DropDownList ID="editLocation" runat="server" /></td> </tr> <tr> <td>Repeat Interval:</td> <td><telerik:RadTextBox ID="editInterval" runat="server" /></td> <td>Max Repeat:</td> <td><telerik:RadTextBox ID="editRepeat" runat="server" /></td> </tr> <tr> <td>Send On Weekends:</td> <td><asp:CheckBox ID="editWeekends" runat="server" /></td> <td>Send On Holidays:</td> <td><asp:CheckBox ID="editHolidays" runat="server" /></td> </tr> <tr> <td colspan="4"><telerik:RadButton ID="editSubmit" runat="server" Text="Submit" /></td> </tr> </table> </FormTemplate> </EditFormSettings> </telerik:RadTreeList>C#
protected void notificationTree_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e) { if (e.Item is TreeListEditableItem && (e.Item as TreeListEditableItem).IsInEditMode) { TreeListEditableItem item = (TreeListEditableItem)e.Item; RadTextBox txt = (RadTextBox)item.FindControl("editName"); txt.Text = "Test22"; } }0
William
Top achievements
Rank 1
answered on 19 Dec 2011, 07:13 PM
Fixed the issue by adding the following line to the IF statement check:
(e.Item.ItemType == TreeListItemType.EditFormItem)