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 Telerik.Web.UI;

public partial class UpdateControlWithAJAXDependingOnClickedToolbarButtonCS_WebUI : System.Web.UI.Page
{
    private String updateControlID;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
        
    protected void RadToolbar1_OnClick(object sender, RadToolBarEventArgs e)
    {
        RadToolBarButton button = e.Item as RadToolBarButton;

        switch (button.CommandName)
        {
            case "New":
                {
                    ListBox1.Items.Add(new ListItem((ListBox1.Items.Count + 1).ToString()));
                    updateControlID = "ListBox1";
                    break;
                };

            case "Save":
                {
                    for (int i = CheckBoxList1.Items.Count; i < ListBox1.Items.Count; i++)
                    {
                        CheckBoxList1.Items.Add(new ListItem((i + 1).ToString()));
                    }
                    updateControlID = "CheckBoxList1";
                    break;
                }
        }

    }
}
