Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1740
How to display DropDownList in RowEditingTemplate
posted

How can I make a column as DropDownList using DropDownProvider in RowEditingTemplate? The sample shows the DropDownList in edit mode within the cell https://es.infragistics.com/samples/aspnet/data-grid/dropdown-editors

Parents Reply Children
  • 1440
    posted in reply to showkath

    Hi Mike,

    This thread was just what I was looking for to be able to put a WebDropDown control in a RowEditingTemplate.  Thank you.  However, I've noticed a  behavior when using the control where the previously selected value remains selected (either highlighted or the background is grayed).

    Given In the screen shoot, when I selected the highlighted row, the value of 'Michigan' was replaced with the last value that I selected which is 'Arizona' from the previous row.  Also notice that "Albuquerque', 'Arizona', 'Boise' and the row under 'Cascades' are either selected or the background is grayed. They were also selected for rows towards the top of the grid.

    Below is the code used in the markup and the codebehind

    <ig:RowEditingClientBinding ColumnKey="Territory" ControlID="control_Territory"             GetValueJavaScript="$find({ClientID}).get_selectedItem().get_value()"            SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" />

    <div class="lbl">&nbsp;Territory:&nbsp;</div>
       <ig:WebDropDown ID="control_Territory" DisplayMode="DropDownList" DataSourceID="SqlDataSource2"
          TextField="mktgrpname" ValueField="mktgrpname" runat="server" Width="250px"
          EnableDropDownAsChild="true" ClientEvents-Initialize="setZIndex"  DropDownOrientation="Default"
          DropDownItemBinding-TextField="mktgrpname" DropDownItemBinding-ValueField="mktgrpname">
       </ig:WebDropDown>
    </div>


    Protected Sub GridView_RowSelectionChanged(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.SelectedRowEventArgs) Handles GridView.RowSelectionChanged

            Dim DDLB As WebDropDown = _
                TryCast(GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("control_Territory"), WebDropDown)
            If Not IsNothing(DDLB) Then
                If e.CurrentSelectedRows.Count > 0 Then
                    DDLB.ClearSelection()
                    DDLB.SelectedItemIndex = -1
                    DDLB.DataBind()
                    DDLB.CurrentValue = e.CurrentSelectedRows.Item(0).Items(14).Value
                    DDLB.SelectedValue = e.CurrentSelectedRows.Item(0).Items(14).Value
                End If
            End If

        End Sub

    What do I need to do to have all previously selected entries deselected (not highlighted and the background white) and highlight the currently selected rows entry highlighted?

    Thanks in advance.