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

Attach an event to a GridDropDownColumn

3 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
myrad
Top achievements
Rank 1
myrad asked on 02 Jul 2010, 07:45 PM
HI guys,

I am using two GridDropDownColumn inside RadGrid.

1- DropDownList is AssetType
2- DropDownList is Category

What I am trying to do is this:

When user select value from first dropdown list (AssetType), I need to get the asset type value so I can update the values in second dropdown list (category).

So bit of research I found some help, which is to attach an event to a GridDropDownColumn. I have found this code on many forums to attach an event


SomeList.ComboBoxControl.SelectedIndexChanged = New RadComboBoxSelectedIndexChangedEventHandler(AddressOf ComboBoxControl_SelectedIndexChanged)

 

 

 

Protected Sub ComboBoxControl_SelectedIndexChanged(ByVal sender as Object, ByVal e as RadComboBoxSelectedIndexChangedEventArgs)

    ' code goes here
End Sub



But when I try to attach an event in my code my list doesn't give me 'SelectedIndexChanged'  option instead it gives me 'SelectedIndex' option. 

To cut long story short can you please tell me with example how to attach an event to a GridDropDownColumn and also check below code and tell me what I am doing wrong.

 



Private Sub AssetGrid_ItemCreated(ByVal sender as Object, ByVal e as Telerik.Web.UI.GridItemEventArgs) Handles AssGrid.ItemCreated

If TypeOf e.Item Is GridEditableItem AndAlso (e.Item.IsInEditMode) Then

 

Dim editableItem as GridEditableItem = DirectCast(e.Item, GridEditableItem)

 

‘ Get the asset list

 

Dim assetList As GridDropDownListColumnEditor = TryCast(editableItem.EditManager.GetColumnEditor(“AssetTypeID”) , GridDropDownListColumnEditor)

 

AssetList.ComboBoxControl.AutoPostBack = True

 

AssetList.ComboBoxControl.SelectedIndex = New RadComboBoxSelectedIndexChangedEventHandler(AddressOf ComboBoxControl_SelectedIndexChanged)

 

End If

Protected Sub ComboBoxControl_SelectedIndexChanged(ByVal sender as Object, ByVal e as RadComboBoxSelectedIndexChangedEventArgs)

    ' code goes here
End Sub



Its urgent!

Many Thanks 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Jul 2010, 06:07 AM
Hi,

You need to access the DropDownList control rendered in edit mode (RadComboBox if DropDownControlType is set as RadComboBox) and then attach SelectedIndexChanged instead of accessing GridDropDownListColumnEditor.

You can find example in the following documentation:
Attaching event for an auto-generated grid column editor


-Shinu.
0
Larry
Top achievements
Rank 1
answered on 15 Jul 2010, 04:17 PM
Taking this one step further now that I've attached an event to the GridDropDownColumn how do I update another cell in the grid. Based on the SelectedValue I want to default a price in another grid cell.
0
Mira
Telerik team
answered on 20 Jul 2010, 12:23 PM
Hello Larry,

I have followed your scenario and prepared a sample project implementing it. You can find it attached to this message.

Please take a look at it and let me know whether it helps.

Kind regards,
Mira
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
myrad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Larry
Top achievements
Rank 1
Mira
Telerik team
Share this question
or