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

ItemCreated Event

2 Answers 125 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 2
Tina asked on 31 Oct 2012, 08:35 PM
I am having issues setting the event handler for the itemcreated and itemdatabound events.  I get a compile error of  'trvAssignedTo_ItemCreated' is not a member of the project.  But the onNeedDataSource works fine.

<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
        <telerik:RadTreeList ID="trvAssignedTo" runat="server" ParentDataKeyNames="ParentID" DataKeyNames="CampusID" OnItemCreated="trvAssignedTo_ItemCreated" OnItemDataBound="trvAssignedTo_ItemDataBound" onNeedDataSource="trvAssignedTo_NeedDataSource" AutoGenerateColumns="false" NoRecordsText="Not Subscribed to Groups">
            <Columns>
                <telerik:TreeListBoundColumn DataField="CampusName" UniqueName="Campus" HeaderText="Campus" />
                <telerik:TreeListBoundColumn DataField="Department" UniqueName="Department" HeaderText="Department" />
                <telerik:TreeListBoundColumn DataField="Description" UniqueName="Group" HeaderText="Group" />
            </Columns>
        </telerik:RadTreeList>
    </div>
    </form>
</body>
 
    Private Sub trvAssignedTo_ItemCreated(sender As Object, e As TreeListItemCreatedEventArgs)
        If TypeOf e.Item Is TreeListHeaderItem Then
            If csSession.sessionCompanyType = "L" Then
                Dim item As TreeListHeaderItem = TryCast(e.Item, TreeListHeaderItem)
                item("Campus").Text = "League"
                item("Department").Text = "Division"
                item("Group").Text = "Team"
            End If
        End If
    End Sub
    Private Sub trvAssignedTo_ItemDataBound(sender As Object, e As TreeListItemDataBoundEventArgs)
        If TypeOf e.Item Is TreeListDataItem Then
            Dim item As TreeListDataItem = TryCast(e.Item, TreeListDataItem)
            If Not DataBinder.Eval(item.DataItem, "ParentID") Is System.DBNull.Value Then
                item("Campus").Font.Italic = True
            End If
        End If
    End Sub
    Protected Sub trvAssignedTo_NeedDataSource(ByVal source As Object, ByVal e As TreeListNeedDataSourceEventArgs)
        Dim dt As DataTable = csSubscribers.getSubscriberGroups(2)
        trvAssignedTo.DataSource = dt
    End Sub

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 05 Nov 2012, 05:13 PM
Hi Tina,

Attached to this message is a sample runnable project where the ItemCreated event fires without problems. Check it out and see what is the difference in your case.

I hope this helps.

Regards,
Pavlina
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
Tina
Top achievements
Rank 2
answered on 07 Nov 2012, 04:53 PM
I have the events as private.  When I changed to protected it works fine.
Tags
TreeList
Asked by
Tina
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Tina
Top achievements
Rank 2
Share this question
or