This is a migrated thread and some comments may be shown as answers.

Cascading ComboBoxes with radgrid

1 Answer 260 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
KinG
Top achievements
Rank 1
KinG asked on 13 Mar 2019, 04:39 AM
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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 15 Mar 2019, 08:28 AM
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.
Tags
ComboBox
Asked by
KinG
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or