Batch Update in RADGRID using XML as Datasource

Thread is closed for posting
5 posts, 0 answers
  1. FD4BB7E9-09DE-4645-AF12-498D9617F195
    FD4BB7E9-09DE-4645-AF12-498D9617F195 avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 May 2007 Link to this post


    RadGrid version


    .NET version


    Visual Studio version

    VS 2005

    programming language


    browser support

    all browsers supported by RadGrid


    This project is an extension of the online project from the RadGrid Quick Start Framework. In this sample I have added two link buttons “EditAll” and “UpdateAll” in the CommandItemTemplate to incorporate the EditAll and UpdateAll functionality.

    Below are the relevant code snippets:
    protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)  
            if (e.CommandName == "UpdateAll")  
            if (e.CommandName == "EditAll")  
                foreach (GridItem item in RadGrid1.MasterTableView.Items)  
                    if (item is GridEditableItem)  
                        GridEditableItem editableItem = item as GridDataItem;  
                        editableItem.Edit = true;  
     private void UpdateAll()  
            foreach (GridEditableItem item in RadGrid1.EditItems)  
                Hashtable ht = new Hashtable();  
                RadGrid1.MasterTableView.ExtractValuesFromItem(ht, item);  
                String customerID = RadGrid1.MasterTableView.DataKeyValues[item.ItemIndex]["CustomerID"].ToString();  
                XmlNode node =  
                     String.Format("Customers/Customer[@CustomerID='{0}']", customerID));  
                node.Attributes["CompanyName"].Value = ConvertNullToEmpty(ht["CompanyName"]);  
                node.Attributes["ContactName"].Value = ConvertNullToEmpty(ht["ContactName"]);  
                catch (Exception ex)  
                    lblMsg.Text = ex.Message;  

  2. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    Posted 14 May 2007 Link to this post

    Hello Shinu,

    Thank you for providing an extended version of the online demo regarding data editing with XmlDataSource control. 500 Telerik points were added to your account for the involvement.

    Best regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. 9215CE45-6FE5-488E-A0A0-77887FD386BB
    9215CE45-6FE5-488E-A0A0-77887FD386BB avatar
    52 posts
    Member since:
    Nov 2004

    Posted 16 May 2007 Link to this post

    How would you add functionality to move items up and down the list
  4. 73FCD5D1-3429-4ADB-A7B6-2621A8579331
    73FCD5D1-3429-4ADB-A7B6-2621A8579331 avatar
    39 posts
    Member since:
    Dec 2006

    Posted 24 May 2007 Link to this post

    While I have not done it myself, and assuming that you want to reflect the new order in the source data, I think the following approach should work.
    There are four parts to the solution:
    1.  You need the part of reordering grid records on the client-side; I beleive I have seens posted examples how to do that a while back.
    2.  You need an attribute in the data source to indicate the position of the item; technically you can do without it if the datasource is text/xml file but you will have to rewrite it to physically reflect the new order. The sequence numbers are recommended because the solution is then independent of physical ordering, and is immediately convertible to a database source.  
    3.  You include the position attribute in the grid and make it hidden (or visible if it's relevant to the user). Then on the client-side you need to update these attributes as the row positions change. I guess you will do this by looping over the current client grid page and change the position attribute to the current row number.( Note that if the position numbers are hidden you need to the do this loop only once upon the initiation of the batch update command, since only the final client state is relevant, so it will be done as part of part 4. below)

    4.  The batch update on user's click is done as shown in this example

    -- Arie

    Edit:  o.k. here is the link to the reordering sample:
  5. BAACB1D2-0282-4C17-9E0D-BE56CADC4907
    BAACB1D2-0282-4C17-9E0D-BE56CADC4907 avatar
    1 posts
    Member since:
    May 2012

    Posted 26 May 2012 Link to this post

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.