ItemCreated Event

3 posts, 1 answers
  1. Tina
    Tina avatar
    31 posts
    Member since:
    Sep 2007

    Posted 31 Oct 2012 Link to this post

    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.

        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            <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">
                    <telerik:TreeListBoundColumn DataField="CampusName" UniqueName="Campus" HeaderText="Campus" />
                    <telerik:TreeListBoundColumn DataField="Department" UniqueName="Department" HeaderText="Department" />
                    <telerik:TreeListBoundColumn DataField="Description" UniqueName="Group" HeaderText="Group" />
        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. Answer
    Pavlina avatar
    6187 posts

    Posted 05 Nov 2012 Link to this post

    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.

    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.
  3. Tina
    Tina avatar
    31 posts
    Member since:
    Sep 2007

    Posted 07 Nov 2012 Link to this post

    I have the events as private.  When I changed to protected it works fine.
Back to Top