Rad edit batch edit -- Getting selected item value in edit mode

16 posts, 0 answers
  1. Durga
    Durga avatar
    8 posts
    Member since:
    Feb 2014

    Posted 27 Feb 2014 Link to this post

    All,

    Below is the code for my rad grid, and I want to get the selected item value of the rad combo box "not text" in gridbatchedit command.

     command.NewValues["Description"]   --want to text the selected item value, instead of text

    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();

    }

    }

    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"],

    (DateTime)command.NewValues["Date"], command.NewValues["Time"].ToString(), command.NewValues["Description"]);

    }

     

  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 04 Mar 2014 Link to this post

    Hello Durga,

    Following the scenario I have assembled a test sample but was unable to reproduce the problematic behavior. In my case the value of the RadComboBox was returned to the server instead of the text. Could you please examine the attached website and tell us what differs in your case? If you could modify it so that the problem can be observed that would be great.

    Regards,
    Angel Petrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Durga
    Durga avatar
    8 posts
    Member since:
    Feb 2014

    Posted 04 Mar 2014 in reply to Angel Petrov Link to this post

     

     

    Hello,

    Thank you for response.

    In the attached sample I didn't see any code for
    RadGrid1_BatchEditCommand event.

    The problem what I have is not in attaching the items to rad combo box.

    It is after editing, when updating data to database, I want to pull up TitleID value instead of description (ie, text field instead of value filed)

    foreach (GridBatchEditingCommand command in e.Commands)

                {

                     Hashtable newvalues= command.NewValues;

                       if (command.Type == GridBatchEditingCommandType.Update)

                     {

                       

    //Here I want to pass value field (Title ID) instead of text field (Description)

    //command.newvalues (“description”); --

    }

    }

    Let me know if more information is needed.

    Thanks in advance

     

     

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2014 in reply to Durga Link to this post

    Hi Durga,

    Please try the following code snippet to get the selected RadComboBox DataValueField.

    ASPX:
    <telerik:GridTemplateColumn HeaderText="Description" HeaderStyle-Width="180px" UniqueName="Description" DataField="Description">
        <ItemTemplate>
            <%# Eval("Description")%>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="DescriptionDropDown">
            </telerik:RadComboBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>

    C#:
    protected void RadGrid1_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 ddlDesc = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_Description").FindControl("DescriptionDropDown") as RadComboBox;
             string id = ddlDesc.SelectedValue; // For DataValueField value
             string txt = ddlDesc.Text; //for DataTextField value
         }
       }
     }

    Thanks,
    Princy
  6. Durga
    Durga avatar
    8 posts
    Member since:
    Feb 2014

    Posted 05 Mar 2014 in reply to Princy Link to this post

    Hi Princy,

    Thanks for the response.

    ddlDesc.SelectedValue is returning null value.

    Any other suggestions.

    --Thanks






  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Mar 2014 in reply to Durga Link to this post

    Hi Durga,

    Here is the code snippet which i tried and works fine. Please have a look, i have attached a screen shot of what i obtained.

    ASPX:
    <telerik:GridTemplateColumn HeaderText="ShipName" UniqueName="ShipName" DataField="ShipName">
        <ItemTemplate>
            <%# Eval("ShipName")%>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="DescriptionDropDown" DataTextField="ShipName" DataValueField="OrderID" DataSourceID="SqlDataSource1">
            </telerik:RadComboBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>

    C#:
    if (command.Type == GridBatchEditingCommandType.Update)
    {
      Hashtable newValues = command.NewValues;
      string ID= newValues["ShipName"].ToString(); //Gets the OrderID value
    }

    Please try and let me know.
    Thanks,
    Princy
  8. Durga
    Durga avatar
    8 posts
    Member since:
    Feb 2014

    Posted 06 Mar 2014 in reply to Princy Link to this post





    Hello princy,

    Thanks for your time.

    In  string ID= newValues["ShipName"].ToString(); , I am getting shipname text, but what I want is order Id value, please see my code snippet and snapshot.

     

     

     

     

      <telerik:GridTemplateColumn HeaderText="Description" DataField="Description" UniqueName="Description" HeaderStyle-Width="65%">
         <ItemTemplate>
           <%# Eval("Description") %>
         </ItemTemplate>
         <EditItemTemplate>
         <telerik:RadComboBox runat="server" ID="rdDescription" Width="650"              DataTextField="Description" DataValueField="TitleID"></telerik:RadComboBox>
          </EditItemTemplate>
    </telerik:GridTemplateColumn>
     
    C#
    //Update
      if (command.Type == GridBatchEditingCommandType.Update)
                    {
                            try
                            {
                             string descselectedValue = newvalues["Description"].ToString();                    
                                 
                             }
                       }
     
     
    Protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
            {
                 DataTable dt = new DataTable();
                 dt = IoC.Current.Resolve<IReleaseService>().ReleaseListScheduleTitle().Tables[0];        
                 RadComboBox comboBox = (RadComboBox)sender;   
                foreach (DataRow row in dt.Rows)
                {
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Text = row["Description"].ToString();
                    item.Value = row["TitleID"].ToString();
                    comboBox.Items.Add(item);
                    item.DataBind();
                }
            }

     


    --Thanks,

     

     

  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Mar 2014 in reply to Durga Link to this post

    Hi Durga,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateEditColumn="true" OnBatchEditCommand="RadGrid1_BatchEditCommand">
        <MasterTableView EditMode="Batch" CommandItemDisplay="Top">
            <Columns>
                <telerik:GridTemplateColumn DataField="ShipName">
                    <ItemTemplate>
                        <%# Eval("ShipName")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="RadComboBox1" runat="server"                                               EnableLoadOnDemand="true" ShowMoreResultsBox="true"                                                                                                             OnItemsRequested="RadComboBox1_ItemsRequested">
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    C#:
    protected void RadComboBox1_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        string query = "select OrderID,ShipName from Orders";
        RadComboBox comboBox = (RadComboBox)sender;
        SqlDataSource1.SelectCommand = query;
        comboBox.DataSourceID = "SqlDataSource1";
        comboBox.DataTextField = "ShipName";
        comboBox.DataValueField = "OrderID";
        comboBox.DataBind();
    }
    protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        foreach (GridBatchEditingCommand command in e.Commands)
        {
            if (command.Type == GridBatchEditingCommandType.Update)
            {
                Hashtable newValues = command.NewValues;
                Hashtable oldValues = command.OldValues;
                string OrderID = newValues["ShipName"].ToString();
            }
        }
    }

    Thanks,
    Princy.
  10. Olivier
    Olivier avatar
    2 posts
    Member since:
    Sep 2013

    Posted 14 Sep 2014 Link to this post

    I have exactly same problem - Any help please?
  11. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 18 Sep 2014 Link to this post

    Hello Olivier,

    Please share with us the markup and code-behind of the page so we could examine the implementation. Additionally please elaborate on the exact version of the controls used in the application.

    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  12. Sreekanth
    Sreekanth avatar
    5 posts
    Member since:
    Sep 2014

    Posted 18 Nov 2014 Link to this post

    Hi Admin,

    I have similar issue. In IE8, for batch editing, drop down list is not populating in edit mode. Any idea? please let me know.

    Thanks,
    Sreekanth
  13. Sreekanth
    Sreekanth avatar
    5 posts
    Member since:
    Sep 2014

    Posted 18 Nov 2014 Link to this post

    forgot to add code in my earlier post,

    aspx
    ========
    <%@ Page Title="" Language="C#"  AutoEventWireup="true"
        CodeFile="CWAvailabilityDetailsChildBatchEdit.aspx.cs" Inherits="CWAvailabilityDetailsChildBatchEdit" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <body>
    <form runat="server" id="form1">


                 <div id="Ajax_ScriptManager">
          <ajaxToolkit:ToolkitScriptManager runat="server" ID="ajaxScriptManager1" EnablePartialRendering="true"
                />
           <%--        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rdDetails">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rdDetails"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>--%>
       <%-- <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>--%>
        </div>

    <div align="center">
      
      <asp:Panel ID="pnlPrimaryInfo" runat="server" Width="98%" BorderWidth="1px" BorderColor="#2F97E8" CssClass="wizFont">
        <table id="table1" runat="server" cellspacing="1" cellpadding="1" width="100%" border="0">
            <tr>
                <td>
                
      
              
                


         <h3> Case Worker Availability </h3>
        <telerik:RadGrid runat="server" ID="rdGridDetail" AllowPaging="false" AllowSorting="false"  OnNeedDataSource="rdGridDetail_NeedDataSource" 
                       OnPreRender ="rdGridDetail_PreRender" AutoGenerateColumns="False" GridLines="none" OnBatchEditCommand="rdGridDetail_BatchEditCommand"  
                       AllowAutomaticUpdates="True">
                      
                          <MasterTableView Width="100%" EditMode="Batch" CommandItemDisplay ="Bottom" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false" >
                           <BatchEditingSettings EditType="Cell"  />
                              <Columns>
                                <telerik:GridBoundColumn  HeaderText="Date" DataField="Available_Date" ReadOnly="true" ></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn  HeaderText="Available Hours" DataField="Available_Hours" ></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn  HeaderText="Non Available Hours" DataField="Non_Avail_Hours" ></telerik:GridBoundColumn>
                               <%--<telerik:TemplateColumn  HeaderText="Non Avail Reason" DataField="Non_Avail_Reason" ></telerik:GridBoundColumn>--%>
                               <telerik:GridTemplateColumn HeaderText="Non Avail Reason" HeaderStyle-Width="180px" UniqueName="NonAvailReasonId" DataField="Non_Avail_Reason" >
                                    <ItemTemplate>
                                        <%# Eval("Non_Avail_Reason")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                       <telerik:RadDropDownList ID="ddlNonAvailReason" runat="server" DefaultMessage=" Please select "
                                            Width="205px"  SelectedValue='<%# Bind("Non_Avail_Reason") %>' >
                                            <Items>
                                                <telerik:DropDownListItem Text="AL"            Value="1" />
                                                <telerik:DropDownListItem Text="AL Partial"    Value="2" />
                                                <telerik:DropDownListItem Text="SL"                 Value="3" />
                                                <telerik:DropDownListItem Text="SL - Partial"       Value="4" />
                                                <telerik:DropDownListItem Text="Unplanned AL"       Value="5" />
                                                <telerik:DropDownListItem Text="Unplanned SL"       Value="6" />
                                                <telerik:DropDownListItem Text="FML"                Value="7" />
                                                <telerik:DropDownListItem Text="Meeting"            Value="8" />
                                                <telerik:DropDownListItem Text="Meeting - Partial"  Value="9" />
                                                <telerik:DropDownListItem Text="Reduction - Partial" Value="10" />
                                                <telerik:DropDownListItem Text="Training"           Value="11" />
                                                <telerik:DropDownListItem Text="Training - Partial" Value="12" />
                                                <telerik:DropDownListItem Text="Admin"              Value="13" />
                                                <telerik:DropDownListItem Text="Admin Partial"      Value="14" />
                                                <telerik:DropDownListItem Text="Other Assignment"   Value="15" />
                                                <telerik:DropDownListItem Text="Other Assignment - Partial" Value="16" />
                                                <telerik:DropDownListItem Text="Lobby Coverage - Partial" Value="17" />
                                                <telerik:DropDownListItem Text="Lobby Coverage"     Value="18" />
                                                
                                            </Items>
                                        </telerik:RadDropDownList>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn  HeaderText="Date" DataField="Available_Date" Display="false"  UniqueName="Date"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn  HeaderText="Date" DataField="ID" Display="false"  UniqueName="ID"></telerik:GridBoundColumn>
                            </Columns>
                              </MasterTableView>
                 
                    <%--<ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                        <Selecting AllowRowSelect="True"></Selecting>
                        <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True"
                        ResizeGridOnColumnResize="False"></Resizing>
                    </ClientSettings>
                    <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>--%>
        </telerik:RadGrid>
         <telerik:RadListBox runat="server" ID="SavedChangesList" Width="100%" Height="200px" Visible="false"></telerik:RadListBox>
        <br />

     
              </td>
            </tr>       
        </table>
      </asp:Panel>
     

    Note: This is working fine in Chrome, but not in IE8. please let me know if i need to provide any other details.

  14. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 21 Nov 2014 Link to this post

    Hello Sreekanth,

    Using the provided code I have assembled a sample website but was not able to observe any abnormalities. In my case the drop down was populated as expected.

    Please examine the attached test sample and tell us what differs in your case. Additionally if you can modify it in such a manner so that the problem can be replicated that would be great. Finally I would recommend removing the AJAX Control Toolkit and its references from the original project and testing the application again.

    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  15. Sreekanth
    Sreekanth avatar
    5 posts
    Member since:
    Sep 2014

    Posted 21 Nov 2014 in reply to Angel Petrov Link to this post

    Angel,

    I have opened a support ticket and below is the update for this issue.  You can check the details in ticket 881044.
    -----------------------------------------
    Hi Sreekanth,

    Thank you for getting back to us.

    Our latest version is 2014.3 1012. Could you please try with that version and see if the issue will be resolved. With version prior to 2014.3 1012 there was some issue related to the DropDownList and the mousedown event of grid, which is fixed in the latest version. The fact that the moving with the keyboard is working correctly is indication that this is related to the bug in question.

    If you observe the same issue with the latest version, please isolate the problem in a sample, runnable project (with dummy data), so we can investigate it locally.

    I am looking forward to your reply.


    Regards,
    Konstantin Dikov 
    Telerik

  16. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 26 Nov 2014 Link to this post

    Hi Sreekanth,

    From the ticket it seems that the initial problem was resolved. If you have any further queries regarding this matter please post them in the official support ticket. Later you can share your finding with the community thus helping other members overcome such type of issue.

    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  17. Sreekanth
    Sreekanth avatar
    5 posts
    Member since:
    Sep 2014

    Posted 02 Dec 2014 in reply to Angel Petrov Link to this post

    Fix for this issue is as I mentioned in my previous post, need to use dlls with version 2014.3 1012 or higher.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017