Hi,
I 'm using Radgrid with three dropdowns for each row. Second dropdown will populate based on the first dropdown selection
and third drop down will populate based on the second drop down selection. (Like Cascading drop down)
Please guide me to do this ....
Any Guidance will be Appreciated!!!!
Thanks
chithuraj.J
I 'm using Radgrid with three dropdowns for each row. Second dropdown will populate based on the first dropdown selection
and third drop down will populate based on the second drop down selection. (Like Cascading drop down)
Please guide me to do this ....
Any Guidance will be Appreciated!!!!
Thanks
chithuraj.J
11 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 22 Jul 2009, 04:19 AM
Hello Chituraj,
I suppose you have placed your dropdowns in three different TemplateColumns as shown below:
aspx:
If so, you can try out the following code to populate one dropdown based on another dropdowns selection:
c#:
You can alter the logic according to your requirement.
Thanks
Princy.
I suppose you have placed your dropdowns in three different TemplateColumns as shown below:
aspx:
<telerik:GridTemplateColumn> |
<ItemTemplate> |
<asp:DropDownList DataSourceID="SqlDataSource1" DataTextField="Continents" ID="DropDownList1" runat="server"> |
</asp:DropDownList> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn> |
<ItemTemplate> |
<asp:DropDownList ID="DropDownList2" runat="server"> |
</asp:DropDownList> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn> |
<ItemTemplate> |
<asp:DropDownList ID="DropDownList3" runat="server"> |
</asp:DropDownList> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
If so, you can try out the following code to populate one dropdown based on another dropdowns selection:
c#:
protected void RadGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem dataItem = (GridDataItem)e.Item; |
DropDownList list1 = (DropDownList)dataItem.FindControl("DropDownList1"); |
list1.AutoPostBack = true; |
list1.SelectedIndexChanged += new EventHandler(list1_SelectedIndexChanged); |
DropDownList list2 = (DropDownList)dataItem.FindControl("DropDownList2"); |
list2.AutoPostBack = true; |
list2.SelectedIndexChanged += new EventHandler(list2_SelectedIndexChanged); |
} |
} |
void list2_SelectedIndexChanged(object sender, EventArgs e) |
{ |
GridDataItem item = (GridDataItem)(sender as DropDownList).NamingContainer; |
DropDownList ddl3 = (DropDownList)item.FindControl("DropDownList3"); |
ddl3.DataSourceID = "SqlDataSource1"; |
ddl3.DataTextField = "Countries"; |
} |
void list1_SelectedIndexChanged(object sender, EventArgs e) |
{ |
GridDataItem item = (GridDataItem)(sender as DropDownList).NamingContainer; |
DropDownList ddl2 = (DropDownList)item.FindControl("DropDownList2"); |
ddl2.DataSourceID = "SqlDataSource1"; |
ddl2.DataTextField = "Cities"; |
} |
Thanks
Princy.
0

chithuraj
Top achievements
Rank 1
answered on 22 Jul 2009, 05:35 AM
Hello Princy,
Thanks for your kind help. It is working Perfect.
Thanks and regards!
chithuraj.j
Thanks for your kind help. It is working Perfect.
Thanks and regards!
chithuraj.j
0

mathieu cupryk
Top achievements
Rank 1
answered on 08 Sep 2009, 01:18 AM
Do you have a list of all cities?
0

Princy
Top achievements
Rank 2
answered on 08 Sep 2009, 06:32 AM
Hi Mathieu,
I'm not really sure as to what you require. But if you want to get all the cities corresponding to a particular country then you can actually download City Databases for the corresponding country from the internet, attach it to your database and populate your control accordingly.
Hope this makes sense.. :)
-Princy.
I'm not really sure as to what you require. But if you want to get all the cities corresponding to a particular country then you can actually download City Databases for the corresponding country from the internet, attach it to your database and populate your control accordingly.
Hope this makes sense.. :)
-Princy.
0

Jeru Catli
Top achievements
Rank 1
answered on 10 Sep 2009, 10:01 AM
could you convert it to vb code? thanks in advance..
0

Shinu
Top achievements
Rank 2
answered on 10 Sep 2009, 10:35 AM
Hello Jeru,
Here's the Vb code for to populate one dropdown based on another dropdowns selection:
vb:
Protected Sub RadGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) |
If TypeOf e.Item Is GridDataItem Then |
Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
Dim list1 As DropDownList = DirectCast(dataItem.FindControl("DropDownList1"), DropDownList) |
list1.AutoPostBack = True |
AddHandler list1.SelectedIndexChanged, AddressOf list1_SelectedIndexChanged |
Dim list2 As DropDownList = DirectCast(dataItem.FindControl("DropDownList2"), DropDownList) |
list2.AutoPostBack = True |
AddHandler list2.SelectedIndexChanged, AddressOf list2_SelectedIndexChanged |
End If |
End Sub |
Sub list2_SelectedIndexChanged(sender As Object, e As EventArgs) |
Dim item As GridDataItem = DirectCast((TryCast(sender, DropDownList)).NamingContainer, GridDataItem) |
Dim ddl3 As DropDownList = DirectCast(item.FindControl("DropDownList3"), DropDownList) |
ddl3.DataSourceID = "SqlDataSource1" |
ddl3.DataTextField = "Countries" |
End Sub |
Sub list1_SelectedIndexChanged(sender As Object, e As EventArgs) |
Dim item As GridDataItem = DirectCast((TryCast(sender, DropDownList)).NamingContainer, GridDataItem) |
Dim ddl2 As DropDownList = DirectCast(item.FindControl("DropDownList2"), DropDownList) |
ddl2.DataSourceID = "SqlDataSource1" |
ddl2.DataTextField = "Cities" |
End Sub |
You can also make use of this code conversion tool to convert c# codes to vb and vice versa.
-Shinu.
0

Meenakshi
Top achievements
Rank 1
answered on 24 Oct 2015, 09:24 AM
I want to load some values in Dropdown 2 based on Dropdown 1 selection inside Radgrid.Kindly help.
Thanks,
Meenu
0

Venkat
Top achievements
Rank 1
answered on 25 Jan 2016, 07:58 AM
Hi, I am facing similar issue like about using cascading dropdowns in Telerik grid. He I am doing CRUD operations using Telerik grid functionality. While creating a new record I have 1 level of cascading dropdowns and I could able to load dropdowns successfully. But after selecting the second dropdown and click on submit button, in 'gvResults_InsertCommand' event dropdown selectedvalue is reset to zero (default). If I donot use the SelectedChanged event for drop down, then I am could able to get the selectedvalue. Please help me on this.
0
Hi,
Please refer to the code library below which demonstrates a similar functionality to the one you are looking for:
http://www.telerik.com/support/code-library/using-cascading-radcomboboxes-into-the-radgrid-insert-edit-form
Regards,
Pavlina
Telerik
Please refer to the code library below which demonstrates a similar functionality to the one you are looking for:
http://www.telerik.com/support/code-library/using-cascading-radcomboboxes-into-the-radgrid-insert-edit-form
Regards,
Pavlina
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0

Venkat
Top achievements
Rank 1
answered on 25 Jan 2016, 11:56 AM
Hi, Thanks for your Information. I think here you have used a custom form for Edit form. But my solution is not using the custom form for Edit / Add item. Can you plz provide help on the solution using Edit /Add items in the same grid for getting selectedValue from dropdown control in Add / Update event?
0
Hello,
Then the following example should help you achieve your goal:
http://www.telerik.com/support/code-library/using-related-radcomboboxes-in-radgrid
Regards,
Pavlina
Telerik
Then the following example should help you achieve your goal:
http://www.telerik.com/support/code-library/using-related-radcomboboxes-in-radgrid
Regards,
Pavlina
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items