Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Cancel Edit mode on button click outside the grid
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Cancel Edit mode on button click outside the grid

Feed from this thread
  • Yogi avatar

    Posted on Oct 23, 2008 (permalink)

    Hi,

    I am facing a problem while working with Raggrid,  I am using  Update  command button  to update record  in a  grid,  when  i clicked on  Edit command  button  the selected records display in edit mode.

    Now my problem begins here, now i am updating records using submit button outside the grid, the code updated the records in a database successfully, but displays the same record is in Editmode after rebinding the grid.

    plzz tell me how i remove this edit mode from grid after rebinding data on button click outside the grid?

    thanks in advance....

  • Posted on Oct 23, 2008 (permalink)

    Hi Yogi,

    Here is the code snippet to clear all items in edit mode on clicking the button outside the Grid.

    CS:
    protected void Button1_Click(object sender, EventArgs e) 
        { 
            //code to perform Update operation 
            RadGrid1.MasterTableView.ClearEditItems(); 
        } 



    Regards
    Shinu.

  • Yogi avatar

    Posted on Oct 23, 2008 (permalink)

    thanks for reply.

    I am using this code snippet for update grid data on button click. but still not working for me.....

    please help me out....

     protected void btnSubmit_Click(object sender, EventArgs e)
        {
            UpdateOrder();
           Radgrid1.MasterTableView.ClearEditItems();
           Radgrid1.Rebind();
        }

     public void UpdateOrder()
        {
            MyClass wDB = new MyClass();
            System.Xml.XmlDataDocument xmldoc = new System.Xml.XmlDataDocument();
            System.Xml.XmlElement data = xmldoc.CreateElement("data");
            xmldoc.AppendChild(data);
           
            foreach (GridItem item in Radgrid1.MasterTableView.Items)
            {
                CheckBox chkSelect = (item as GridEditableItem)["clmSelect"].Controls[0] as CheckBox;

                if ((item is GridEditableItem) && ((item.IsInEditMode) || (chkSelect.Checked == true)))
                {
                  
                    RadNumericTextBox numtxtbxSent = (item as GridEditableItem)["colQty1"].Controls[0] as RadNumericTextBox;
                    System.Xml.XmlElement qtyUpdate = xmldoc.CreateElement("recOrdUpdate");
                    TextBox txt = (item as GridDataItem)["colId"].Controls[0] as TextBox;

                    RadDatePicker receiveDate = (item as GridEditableItem)["colDate"].Controls[1] as RadDatePicker;
                    receiveDate.DateInput.DbSelectedDate = receiveDate.Calendar.SelectedDate;
               
                    qtyUpdate.SetAttribute("id", txt.Text);
                    qtyUpdate.SetAttribute("qty1", numtxtbxSent.Value.ToString());
                    qtyUpdate.SetAttribute("receivedDate", receiveDate.DateInput.DbSelectedDate.ToString());
           data.AppendChild(qtyUpdate);
                                 
                }
              
            }

            string xmldata = xmldoc.OuterXml.ToString();
            XElement xmlElementTree = XElement.Parse(xmldata, LoadOptions.None);
         
            //Passing parameter to a function for update
                    
     }

    On aspx page:
    <CommandItemTemplate>
                                         <div id="footer1" runat="server" style="height: 40px; background: #ebecee; width: 100%;
                                            padding-top: 15px; padding-bottom: 15px; margin-left: -2px;">
                                            <table cellpadding="0px" cellspacing="0px" border="0" style="width: 613px">
    <tr>
                                                    <td>
                                                        <asp:LinkButton Style="vertical-align: bottom" ID="btnEditSelected" runat="server" CommandName="EditSelected" CausesValidation="false"
                                                            Visible='<%# Radgrid1.EditIndexes.Count == 0 %>'>
                                                            Edit Selected Products
                                                        </asp:LinkButton>
                                                      
                                                        &nbsp;
                                                        <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" CausesValidation="false" Visible='<%# Radgrid1.EditIndexes.Count > 0 || Radgrid1.MasterTableView.IsItemInserted %>'>
                                                            Cancel editing
                                                        </asp:LinkButton>
                      
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
     </CommandItemTemplate>
           

  • Yogi avatar

    Posted on Oct 23, 2008 (permalink)

    thanks for reply.

    I am using this code snippet for update grid data on button click. but still not working for me.....

    please help me out....

     protected void btnSubmit_Click(object sender, EventArgs e)
        {
            UpdateOrder();
           Radgrid1.MasterTableView.ClearEditItems();
           grdSearchResult.Rebind();
        }

     public void UpdateOrder()
        {
            MyClass wDB = new MyClass();
            System.Xml.XmlDataDocument xmldoc = new System.Xml.XmlDataDocument();
            System.Xml.XmlElement data = xmldoc.CreateElement("data");
            xmldoc.AppendChild(data);
           
            foreach (GridItem item in Radgrid1.MasterTableView.Items)
            {
                CheckBox chkSelect = (item as GridEditableItem)["clmSelect"].Controls[0] as CheckBox;

                if ((item is GridEditableItem) && ((item.IsInEditMode) || (chkSelect.Checked == true)))
                {
                  
                    RadNumericTextBox numtxtbxSent = (item as GridEditableItem)["colQty1"].Controls[0] as RadNumericTextBox;
                    System.Xml.XmlElement qtyUpdate = xmldoc.CreateElement("recOrdUpdate");
                    TextBox txt = (item as GridDataItem)["colId"].Controls[0] as TextBox;

                    RadDatePicker receiveDate = (item as GridEditableItem)["colDate"].Controls[1] as RadDatePicker;
                    receiveDate.DateInput.DbSelectedDate = receiveDate.Calendar.SelectedDate;
               
                    qtyUpdate.SetAttribute("id", txt.Text);
                    qtyUpdate.SetAttribute("qty1", numtxtbxSent.Value.ToString());
                    qtyUpdate.SetAttribute("receivedDate", receiveDate.DateInput.DbSelectedDate.ToString());
           data.AppendChild(qtyUpdate);
                                 
                }
              
            }

            string xmldata = xmldoc.OuterXml.ToString();
            XElement xmlElementTree = XElement.Parse(xmldata, LoadOptions.None);
         
            //Passing parameter to a function for update
                    
     }


    aspx:

    <CommandItemTemplate>
        <div id="footer1" runat="server" style="height: 40px; background: #ebecee; width: 100%;
                                            padding-top: 15px; padding-bottom: 15px; margin-left: -2px;">
                                            <table cellpadding="0px" cellspacing="0px" border="0" style="width: 613px">
     <tr>
                                                    <td>
                                                        <asp:LinkButton Style="vertical-align: bottom" ID="btnEditSelected" runat="server" CommandName="EditSelected" CausesValidation="false"
                                                            Visible='<%# Radgrid1.EditIndexes.Count == 0 %>'>
                                                            Edit Selected Products
                                                        </asp:LinkButton>
                                                      
                                                        &nbsp;
                                                        <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" CausesValidation="false" Visible='<%# Radgrid1.EditIndexes.Count > 0 || Radgrid1.MasterTableView.IsItemInserted %>'>
                                                            Cancel editing
                                                        </asp:LinkButton>
                      
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>                                 
                                           
     </CommandItemTemplate>
           

  • abinav avatar

    Posted on Jun 21, 2011 (permalink)

    RadGrid1.MasterTableView.IsItemInserted = false;
     RadGrid1.EditIndexes.Clear();
     RadGrid1.MasterTableView.Rebind();

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Cancel Edit mode on button click outside the grid