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
515
Defaulting selected index of a EditorControl dropdown based on the selection of another editor control dropdown
posted

Hi

I'm implementing dropdown list defaulting based on selection while editing/adding a row on a webdatagrid. I have the events firing for selected index changed and data bound, but can't seem to set the selected index, i've tried      

          ddlUnitID.EditorControl.Items[2].Selected = true;
          ddlUnitID.EditorControl.SelectedValue = ddlUnitID.EditorControl.Items[2].Value;
          ddlUnitID.EditorControl.SelectedItemIndex = 2;

all seem to not select the item in the dropdopdown on the editing row. I've tried this both on selection changed and ondatabound.

 <ig:WebDataGrid ID="WebDataGrid1" runat="server"   AutoGenerateColumns="False" OnRowUpdating="WebDataGrid1_RowUpdating" AutoGenerateBands="true" ViewStateMode="Disabled"
                                DataKeyFields="ID" Width="98%" OnRowAdded="WebDataGrid1_RowAdded" OnRowAdding="WebDataGrid1_RowAdding" OnRowsDeleting="WebDataGrid1_RowDeleting" >
                                <Columns>
                                    <ig:BoundDataField Hidden="true" DataFieldName="ID" Key="ID" >
                                        <Header Text="ID" />
                                    </ig:BoundDataField>
                                    <ig:BoundDataField DataFieldName="Ordinal" Key="Ordinal">
                                        <Header Text="Process No." />
                                    </ig:BoundDataField>
                                    <ig:BoundDataField DataFieldName="MaterialID" Key="Material">
                                        <Header Text="Material" />
                                    </ig:BoundDataField>
                                      <ig:BoundDataField DataFieldName="QTY" Key="GROSS">
                                        <Header Text="Quantity" />
                                    </ig:BoundDataField>
                                    <ig:BoundDataField DataFieldName="UnitQTYID" Key="UOM">
                                        <Header Text="Unit" />
                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="UnitQTY" Key="COUNT">
                                        <Header Text="Weight" />
                                    </ig:BoundDataField>
                                    
                                  
                                    <ig:BoundDataField DataFieldName="UnitID" Key="WUOM">
                                        <Header Text="Weight Unit" />
                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="Comments" Key="NET">
                                    
                                        <Header Text="Comments" />
                                    </ig:BoundDataField>

                                      <ig:TemplateDataField Key="DeleteItem" Width="60px">
                                      <Header Text="Delete" />
                        <ItemTemplate>
                            <asp:LinkButton runat="server" ID="DeleteItem" Text="X"
                                OnClientClick="DeleteRow(); return false;" />

                        </ItemTemplate>
                    </ig:TemplateDataField>

                                </Columns>
                                <EditorProviders>
                                    <ig:DropDownProvider ID="ddlMaterialID">
                                        <EditorControl ID="ddlMatID" runat="server" DisplayMode="DropDown" TextField="NAME" OnSelectionChanged="ddlMatID_SelectionChanged"
                                            ValueField="ID" DataSourceID="srcMaterial" AutoPostBackFlags-SelectionChanged="Async">
                                        </EditorControl>
                                    </ig:DropDownProvider>
                                     <ig:DropDownProvider ID="ddlUnitID">
                                        <EditorControl ID="ddlUnID" runat="server" DisplayMode="DropDown" TextField="UNIT_NAME"
                                            ValueField="ID" DataSourceID="srcUnit" OnDataBound="ddlUnitID_DataBound">
                                        </EditorControl>
                                    </ig:DropDownProvider>
                                   
                                      <ig:DropDownProvider ID="ddlWUnitID" >
                                        <EditorControl ID="ddlWUnID" runat="server" DisplayMode="DropDown" TextField="UNIT_NAME"
                                            ValueField="ID" DataSourceID="srcWUnit">
                                        </EditorControl>
                                    </ig:DropDownProvider>
                                    <ig:NumericEditorProvider ID="txtUOM">
                                    </ig:NumericEditorProvider>
                                    <ig:NumericEditorProvider ID="txtQuantity">
                                    </ig:NumericEditorProvider>
                                </EditorProviders>
                                <Behaviors>
                                    <ig:Activation />
                                   
                                    <ig:Selection RowSelectType="Multiple" CellClickAction="Row" />
                                     <ig:Sorting SortingMode="Single" Enabled="true" />
                                      <ig:ColumnMoving>
                    </ig:ColumnMoving>
                    <ig:ColumnResizing>
                    </ig:ColumnResizing>

                                    <ig:EditingCore>
                                        <Behaviors>
                                            <ig:CellEditing Enabled="true">
                                                <EditModeActions EnableF2="true" EnableOnActive="true" MouseClick="Single" />
                                                <ColumnSettings>
                                                    <ig:EditingColumnSetting ColumnKey="ID" ReadOnly="true" />
                                                    <ig:EditingColumnSetting ColumnKey="Material" EditorID="ddlMaterialID" />
                                                    <ig:EditingColumnSetting ColumnKey="COUNT" EditorID="txtQuantity" />
                                                    <ig:EditingColumnSetting ColumnKey="UOM" EditorID="ddlUnitID" />
                                                    <ig:EditingColumnSetting ColumnKey="WUOM" EditorID="ddlWUnitID" />
                                                </ColumnSettings>
                                            </ig:CellEditing>
                                              <ig:RowAdding Alignment="Bottom" EditModeActions-EnableOnActive="true" EditModeActions-MouseClick="Single"
                                              Enabled="true" >
                                                <AddNewRowClientEvents ExitedEditMode="WebDataGridView_ExitedEditMode" />
                                                <ColumnSettings>
                                                 <ig:RowAddingColumnSetting ColumnKey="ID" ReadOnly="true" />
                                                    <ig:RowAddingColumnSetting ColumnKey="Material" EditorID="ddlMaterialID" />
                                                    <ig:RowAddingColumnSetting ColumnKey="COUNT" EditorID="txtQuantity" />
                                                    <ig:RowAddingColumnSetting ColumnKey="UOM" EditorID="ddlUnitID" />
                                                    <ig:RowAddingColumnSetting ColumnKey="WUOM" EditorID="ddlWUnitID" />
                                                </ColumnSettings>
                                </ig:RowAdding>
                                  <ig:RowDeleting Enabled="true" />
                                        </Behaviors>
                                    </ig:EditingCore>
                                </Behaviors>
                                <ClientEvents AJAXResponse="WebDataGridView_AJAXResponse" />
                            </ig:WebDataGrid>

Using 2013.2 ASP.net and C#.
Thanks

Ten

Parents Reply Children