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

RadGrid EditItemTemplate RadComboBox selected items are empty in RadGrid BatchEdit event

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Santhosh
Top achievements
Rank 1
Veteran
Santhosh asked on 02 Sep 2020, 05:21 PM

Hi 
I am unable to get the RadGrid EditItemTemplate RadComboBox with checkboxes=ture selected items are empty in RadGrid BatchEdit event. Basically I put the RadComboBox in RadGrid EditItemTemplate and selecting the multiple of RadCombo box and try get those selected item in RadGrid BatchEdit event to save into db, but RadComboBax seletedItems count is empty and I am not able to get the selected items of RadcomboBox. 
Instead of RadComboBax if I use the DropDownList I am to get the selected value in Grid BatchEdit event, but my requirement is need to seleted the more than one item so I am using RadComboBox. Here the below is my code. 

<telerik:RadListBox RenderMode="Lightweight" runat="server" ID="SavedChangesList" Width="600px" Height="200px" Visible="false"></telerik:RadListBox>
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" PageSize="10" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
            OnPreRender="RadGrid1_PreRender" AllowAutomaticUpdates="True" AllowPaging="True"

            AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnBatchEditCommand="RadGrid_BatchEditCommand">
            <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="GLAccountMaintenanceID,Region"
                DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False" EditMode="Batch">
                <BatchEditingSettings EditType="Row" HighlightDeletedRows="true"/>
                <Columns>
                     <telerik:GridBoundColumn UniqueName="GLAccountMaintenanceID"  HeaderText="GLAccountMaintenanceID" DataField="GLAccountMaintenanceID" HeaderStyle-Width="50px">
                     </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Region" DefaultInsertValue="Beverages" HeaderStyle-Width="100px" UniqueName="Region" DataField="Region">
                        <ItemTemplate>
                            <%# Eval("Region") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="radComboBox" RenderMode="Lightweight" DropDownAutoWidth="Enabled" runat="server" AutoPostBack="false" EnableLoadOnDemand="true" DataValueField="RegionId"
                                DataTextField="RegionDesc" DataSourceID="SqlDataSource2" CheckBoxes="false">
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px"
                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=HGT-LAP-085;Initial Catalog=TexasHealthQA;UID=sa;Password=Hallmark123"
        DeleteCommand="DELETE FROM [GlAccountMaintenanceConfig] WHERE [GLAccountMaintenanceId] = @GLAccountMaintenanceId" InsertCommand="INSERT INTO [GlAccountMaintenanceConfig] ([Region]) VALUES (@Region)"
        SelectCommand="SELECT GLAccountMaintenanceId,Region FROM [GlAccountMaintenanceConfig]"
        UpdateCommand="UPDATE [GlAccountMaintenanceConfig] SET [Region] = @Region WHERE [GLAccountMaintenanceId] = @GLAccountMaintenanceId">
        <DeleteParameters>
            <asp:Parameter Name="GLAccountMaintenanceId" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Region" Type="String"></asp:Parameter>
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="GLAccountMaintenanceId" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="Region" Type="String"></asp:Parameter>
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="Data Source=HGT-LAP-085;Initial Catalog=TexasHealthQA;UID=sa;Password=Hallmark123"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RegionId],[RegionDesc] FROM Region"></asp:SqlDataSource>

 

protected void RadGrid_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            foreach (GridBatchEditingCommand command in e.Commands)
            {
                if (command.Type == GridBatchEditingCommandType.Update)
                {
                    Hashtable newValues = command.NewValues;
                    Hashtable oldValues = command.OldValues;
                    RadComboBox radcombo = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_Region").FindControl("radComboBox") as RadComboBox;
                    string radcomboitems = string.Empty;
                    foreach (var item in radcombo.CheckedItems)
                    {
                        radcomboitems = radcomboitems + item.Value + ",";
                    }
                }
            }
        }

 

Please look into this issue and help to me, I am new to Telerik.
Thank you in advance

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 07 Sep 2020, 05:10 AM

Hi Santhosh,

 

I've already replied to your other post on the same matter:
https://www.telerik.com/forums/radgrid-edititemtemplate-radcombobox-selected-items-are-empty-in-radgrid-batchedit-event#0OPDe1oQt0axG7_pkXX_xA

I suggest that we continue our technical discussion on the mentioned thread.

 

Regards,
Eyup
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Santhosh
Top achievements
Rank 1
Veteran
Answers by
Eyup
Telerik team
Share this question
or