using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using APNSoft.WebControls;

public partial class TreeView_CheckBoxes : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        //Apply event-handling method
        cmdPostBack.Click += new EventHandler(cmdPostBack_Click);
    }


    void cmdPostBack_Click(object sender, EventArgs e)
    {

        //Create collection of elements
        myTreeView.DataBind();

        //Get Checked Items
        string CheckedItems = "";
        ArrayList myCheckedItems = myTreeView.GetCheckedItems();
        for (int i = 0; i < myCheckedItems.Count; i++)
        {
            TreeViewElement myItem = (TreeViewElement)myCheckedItems[i];
            CheckedItems += myItem.title + " (" + myItem.id + ") " + "<br/>";
        }

        //Display Checked Items
        lblCheckedItems.Text = CheckedItems;
    }
}