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

Radgrid batch edit --- how to get rad drop down selected value

1 Answer 534 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Durga
Top achievements
Rank 1
Durga asked on 27 Feb 2014, 09:59 PM
Hello All.

I am using rad grid with batch editing ,  in the edit mode I am changing the radcombobox description value and want pass the selected value to database.

on the grid batch edit command for command type update,  I want to pull the selected value instead of text for command.NewValues["Description"],

    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">    

         <telerik:RadListBox runat="server" ID="SavedChangesList" Width="100%" Height="100px" Visible="false"  ForeColor="Red"></telerik:RadListBox>

    <telerik:RadGrid  id="rgReleaseSchedule" runat="server"  AutoGenerateColumns="false"        OnNeedDataSource="rgReleaseSchedule_NeedDataSource"   OnBatchEditCommand="rgReleaseSchedule_BatchEditCommand" OnPreRender="rgReleaseSchedule_Prerender" AllowAutomaticInserts="true" 

        AllowAutomaticUpdates="true" >

        <MasterTableView  CommandItemDisplay="TopAndBottom"  ClientDataKeyNames="ID,Description" EditMode="Batch"  DataKeyNames="ID,Description" NoMasterRecordsText="No records found"  >       

            <BatchEditingSettings EditType="Cell" />

            <Columns>

                <telerik:GridBoundColumn  HeaderText="ScheduleID" DataField="ID" UniqueName="ID" ></telerik:GridBoundColumn>

              

            

               

              <telerik:GridTemplateColumn   HeaderText="Description" DataField="Description"    ColumnEditorID="TitleID" UniqueName="Description" HeaderStyle-Width="65%" >

                    <ItemTemplate>

                        <%# Eval("Description") %>                                             

                        </ItemTemplate>                  

                    <EditItemTemplate  >

                        <telerik:RadComboBox  runat="server" ID="rdDescription" Width="650" Height="400"   OnClientSelectedIndexChanged="SelectedChanged" AutoPostBack="true"   OnSelectedIndexChanged="rdDescription_selectedIndexChanged"></telerik:RadComboBox>                          

                        <asp:RequiredFieldValidator runat="server" ID="rfvdesc" ErrorMessage="Required" ForeColor="Red" ControlToValidate="rdDescription"  Display="Dynamic" ></asp:RequiredFieldValidator>

                    </EditItemTemplate>

                </telerik:GridTemplateColumn>              

              

                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete" ConfirmText="Are you sure you want to delete this Release?" ConfirmDialogType="RadWindow"

                    ConfirmTitle="Delete" HeaderText="Delete" ButtonType="ImageButton" HeaderStyle-Width="50px">

                </telerik:GridButtonColumn>                                  

               </Columns>

          

                 </MasterTableView>

          <ClientSettings>

          <ClientEvents OnBatchEditCellValueChanging="BatchEditCellValueChanging"  OnBatchEditCellValueChanged="CellValueChanged" OnRowSelected="RowSelected"    OnRowClick="rowClick"/></ClientSettings>

         

     </telerik:RadGrid>

        </telerik:RadAjaxPanel

>






protected void rgReleaseSchedule_BatchEditCommand(object sender, Telerik.Web.UI.GridBatchEditingEventArgs e)

{

try

{

SavedChangesList.Items.Clear();

SavedChangesList.ForeColor = System.Drawing.Color.Red;

foreach (GridBatchEditingCommand command in e.Commands)

{

Hashtable newvalues= command.NewValues;

if (command.Type == GridBatchEditingCommandType.Update)

{

if (command.NewValues["Date"].ToString() != "" && command.NewValues["Time"].ToString() != "" && command.NewValues["Description"].ToString() != "")

{

Int32 result = IoC.Current.Resolve<IReleaseService>().ReleaseListUpdate((Int32)command.Item.OwnerTableView.DataKeyValues[command.Item.ItemIndex]["ID"],

command.NewValues["Description"]);

}

protected void rgReleaseSchedule_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

{

rgReleaseSchedule.DataSource = IoC.Current.Resolve<IReleaseService>().ReleaseListSelect(_userContext.CurrentUser.UserId, Convert.ToInt16(ddlYear.SelectedText));

}

protected void rgReleaseSchedule_Prerender(object sender, EventArgs e)

{

{

SavedChangesList.ForeColor = System.Drawing.Color.Red;

RadComboBox ddlDesc = rgReleaseSchedule.FindControl(rgReleaseSchedule.MasterTableView.ClientID + "_Description").FindControl("rdDescription") as RadComboBox;

var description = IoC.Current.Resolve<IReleaseService>().ReleaseListScheduleTitle();

ddlDesc.DataSource = description;

ddlDesc.DataTextField = "Description";

ddlDesc.DataValueField = "TitleID";

ddlDesc.DataBind();

}

}

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 04 Mar 2014, 03:05 PM
Hello Durga,

Please review the answer provided in the other forum post you have opened for the same issue and verify if the provided demo helps.

Please avoid opening duplicate threads in future so that we could easily track your issue and provide proper in time answers.

Regards,
Maria Ilieva
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
Grid
Asked by
Durga
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or