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 Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         if (!Page.IsPostBack)  
         {  
             LoadCategories();  
         }  
    }

    protected void LoadCategories()  
    {   
         DataTable dt = new DataTable();  
         dt.Columns.Add("id");
         dt.Columns.Add("category_name");

        dt.Rows.Add(new String[]{"1", "cat 1"});
        dt.Rows.Add(new String[]{"2", "cat 2"});
        dt.Rows.Add(new String[]{"3", "cat 3"});
            
         Categories.DataTextField = "category_name";  
         Categories.DataValueField = "id";  
         Categories.DataSource = dt;  
           
         // if datatable is null   
         // do not bind dropdown  
         if(dt.Rows.Count != 0) {  
             Categories.DataBind();  
         }  
     }  
     protected void LoadSubCategories(string categoryID)  
     {  
      
         DataTable dt = new DataTable();  
         dt.Columns.Add("subcategoryID");
         dt.Columns.Add("subcategory_name");

         dt.Rows.Add(new String[]{"1", "subcat 1"});
        dt.Rows.Add(new String[]{"2", "subcat 2"});
        dt.Rows.Add(new String[]{"3", "subcat 3"});
   
         SubCategories.DataTextField = "subcategory_name";  
         SubCategories.DataValueField = "subcategoryID";  
         SubCategories.DataSource = dt;  
         SubCategories.DataBind();  
     }  
     protected void Categories_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
     {  
         //Response.Write("e.Text = " + e.Text + "<br>e.Value = " + e.Value);  
         LoadSubCategories(e.Value.ToString());  
     }  
   
     protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
     {  
         LoadCategories();  
     }  
     protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
     {  
      //   Response.Write("e.Text = " + e.Text + "<br>e.Value = " + e.Value);  
         LoadSubCategories(e.Value.ToString());  
     }   

}
