Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > OnSelectedIndexChanged for editin inplace Grid drop down list

Not answered OnSelectedIndexChanged for editin inplace Grid drop down list

Feed from this thread
  • Jason avatar

    Posted on Jan 22, 2012 (permalink)

    I have a nice grid working, and in place add,edit and delete working great.

    However I am now trying to get a drop down list to trigger the "OnSelectedIndexChanged" event so I can obtain the cost and sell price of the part and place it in the appropriate fields.

    <Columns>
                                                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                                                                            CancelImageUrl="~/Images/cancel_16x16.png" EditImageUrl="~/Images/edit_16x16.png"
                                                                            InsertImageUrl="~/Images/update_16x16.png" UpdateImageUrl="~/Images/update_16x16.png"
                                                                            HeaderStyle-Width="50px">
                                                                            <ItemStyle CssClass="MyImageButton" />
                                                                        </telerik:GridEditCommandColumn>
                                                                        <telerik:GridDropDownColumn DataField="PartId" DataSourceID="qry_Parts" HeaderText="Part"
                                                                            ListTextField="Description" ListValueField="PartId" UniqueName="EditPartId" ColumnEditorID="GridDropDownColumnEditorParts"
                                                                            EnableEmptyListItem="False" HeaderStyle-Width="320px">
                                                                        </telerik:GridDropDownColumn>

    Neither the GridBouncColumn or the referering ColumnEditor allow this event.

    How can I achive this?

    Thanks in advance.
    Attached files

    Reply

  • Posted on Jan 22, 2012 (permalink)

    Hello Jason,

    Try setting DropDownControlType as RadComboBox and attach the event as shown below.
    C#:
    protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name=="")
      {
        GridEditableItem item = (GridEditableItem)e.Item;
        RadComboBox combo = (RadComboBox)item["EditPartId"].Controls[0];
        combo.AutoPostBack = true;
        combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
      }
    }
     void combo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
    }

    -Shinu.

    Reply

  • Jason avatar

    Posted on Jan 23, 2012 (permalink)

    Do you have that solution in VB.

    Thanks

    Reply

  • Jason avatar

    Posted on Feb 8, 2012 (permalink)

    In VB :

    combo.SelectedIndexChanged = New RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged)

    does not work as "SelectedIndexChanged" is not available from list. "OnClientSelectedIndexChanged" is though.

    Pls help.

    Thanks.

    Reply

  • Posted on Feb 8, 2012 (permalink)

    Hello Jason,

    Here is the code in VB.
    VB:
    Protected Sub grid_ItemDataBound(sender As Object, e As GridItemEventArgs)
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode AndAlso e.Item.OwnerTableView.Name = "" Then
            Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
            Dim combo As RadComboBox = DirectCast(item("EditPartId").Controls(0), RadComboBox)
            combo.AutoPostBack = True
            combo.SelectedIndexChanged += New RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged)
        End If
    End Sub
    Private Sub combo_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
    End Sub

    Here is the link for code-converter.
    http://converter.telerik.com/.

    -Shinu.

    Reply

  • Jason avatar

    Posted on Feb 8, 2012 (permalink)

    Shinu,

    Thanks however I believe your conversion is not total correct. I can get this to compile ok, but when I run it , all get is a postback but nothing happens, it doesn't run the "combo_SelectedIndexChanged".

    Protected Sub RadGridQuoteItemParts_ItemDataBound(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
     
            If e.Item.IsInEditMode And e.Item.OwnerTableView.Name = "" Then
                Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
                Dim combo As RadComboBox = DirectCast(item("EditPartId").Controls(0), RadComboBox)
     
                combo.AutoPostBack = True
                AddHandler combo.Load, AddressOf combo_SelectedIndexChanged
     
                'MsgBox(combo.SelectedValue & "handler added")
            End If
     
        End Sub
     
        Private Sub combo_SelectedIndexChanged(ByVal source As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
     
            MsgBox("selected")
     
        End Sub

    Reply

  • KC avatar

    Posted on Feb 8, 2012 (permalink)

    Hi Jason,

    Try wiring the event in RadGridQuoteItemParts_ ItemCreated event instead of in the ItemDataBound event.

    Reply

  • Jason avatar

    Posted on Feb 9, 2012 (permalink)

    Protected Sub RadGridQuoteItemLabour_ItemCreated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
     
            If e.Item.IsInEditMode And e.Item.OwnerTableView.Name = "" Then
                Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
                Dim combo As RadComboBox = DirectCast(item("EditLabourRateId").Controls(0), RadComboBox)
     
                combo.AutoPostBack = True
                AddHandler combo.SelectedIndexChanged, AddressOf EditLabourRateId_SelectedIndexChanged
     
            End If
     
        End Sub
     
        Private Sub EditLabourRateId_SelectedIndexChanged(ByVal source As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
     
            Dim intLabourRateIdToLookup As Integer
            Dim strLabourRatePrices As String
            Dim arrLabourRatePrices() As String
            Dim combo As RadComboBox = DirectCast(source, RadComboBox)
            Dim editItem As GridDataItem = DirectCast(combo.NamingContainer, GridDataItem)
            Dim txtEditGridLabourCostRatePerHour As RadNumericTextBox = DirectCast(editItem("EditGridLabourCostRatePerHour").Controls(0), RadNumericTextBox)
            Dim txtEditGridLabourSellRatePerHour As RadNumericTextBox = DirectCast(editItem("EditGridLabourSellRatePerHour").Controls(0), RadNumericTextBox)
            Dim txtEditGridLabourGSTPercentageToApply As RadNumericTextBox = DirectCast(editItem("EditGridLabourGSTPercentageToApply").Controls(0), RadNumericTextBox)
     
            intLabourRateIdToLookup = e.Value
            'Get Cost and Sell prices
            strLabourRatePrices = returnCostSellPriceForSelectedLabour(intLabourRateIdToLookup)
            arrLabourRatePrices = strLabourRatePrices.Split(";")
     
            'Update Values
            txtEditGridLabourCostRatePerHour.Text = arrLabourRatePrices(0)
            txtEditGridLabourSellRatePerHour.Text = arrLabourRatePrices(1)
            txtEditGridLabourGSTPercentageToApply.Text = arrLabourRatePrices(2)
     
        End Sub

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > OnSelectedIndexChanged for editin inplace Grid drop down list
Related resources for "OnSelectedIndexChanged for editin inplace Grid drop down list"

ASP.NET ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]