Cascading ComboBoxes with radgrid

2 posts, 0 answers
  1. KinG
    KinG avatar
    5 posts
    Member since:
    Aug 2008

    Posted 12 Mar Link to this post

    Hello,

     

    i have facing problem while i tried to Cascading ComboBoxes inside the radgrid.

    my website has to Cascading ComboBoxes first one for Departments and second One for Task List and both working fine but the task combobox while i select any item from the list every time jump to the first item in the list. 

    could you please advice ? kindly find the code below ?

     
    Protected Sub LoadDepartments()
           Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("PayrollConnectionString").ConnectionString)
     
           Dim adapter As New SqlDataAdapter("SELECT IDDepartment, DepartmentCode, DepartmentName, DepartmentCode + '-' + DepartmentName AS FullName FROM MasterDepartments ORDER BY DepartmentName", connection)
           Dim dt As New DataTable()
           adapter.Fill(dt)
     
     
           For i As Integer = 0 To RadGrid1.Items.Count - 1
               DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).DataTextField = "FullName"
               DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).DataValueField = "DepartmentCode"
               DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).DataSource = dt
               DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).DataBind()
     
               DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).Items.Insert(0, New RadComboBoxItem("- Select a Department -"))
     
     
     
           Next
     
       End Sub
     
       Protected Sub LoadTasks()
     
           Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("PayrollConnectionString").ConnectionString)
           Dim dt As New DataTable()
     
     
           For i As Integer = 0 To RadGrid1.Items.Count - 1
               Dim adapter As New SqlDataAdapter("SELECT     id, Category, Title, SortOrder, Colors, IsEditable, IsVisible, Descripion, SUBSTRING(Title, 1, 2) AS Expr1 FROM         dbo.LookUps WHERE     (Category = N'task code') AND (SUBSTRING(Title, 1, 2) = @DeptCode)", connection)
     
     
               adapter.SelectCommand.Parameters.AddWithValue("@DeptCode", DirectCast(RadGrid1.Items(i).FindControl("Department"), RadComboBox).SelectedValue)
     
     
               DirectCast(RadGrid1.Items(i).FindControl("TaskList"), RadComboBox).DataTextField = "Descripion"
               DirectCast(RadGrid1.Items(i).FindControl("TaskList"), RadComboBox).DataValueField = "Expr1"
               DirectCast(RadGrid1.Items(i).FindControl("TaskList"), RadComboBox).DataSource = dt
               DirectCast(RadGrid1.Items(i).FindControl("TaskList"), RadComboBox).DataBind()
     
               DirectCast(RadGrid1.Items(i).FindControl("TaskList"), RadComboBox).Items.Insert(0, New RadComboBoxItem("- Select a task list -"))
               adapter.Fill(dt)
     
           Next
  2. Eyup
    Admin
    Eyup avatar
    3795 posts

    Posted 15 Mar Link to this post

    Hello,

    You can check the following 2 samples for directions how to achieve this implementation:
    https://www.telerik.com/forums/radcombobox-cascading-inside-radgrid#GxsIQqyyPkqj1Za-mNbalg

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top