Batch Update in RADGRID using XML as Datasource

5 posts, 0 answers
  1. Shinu
    Shinu 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. Sebastian
    Sebastian avatar
    9934 posts

    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. David Sitton
    David Sitton 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. Arie Segev
    Arie Segev 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. Alan
    Alan avatar
    1 posts
    Member since:
    May 2012

    Posted 26 May 2012 Link to this post

Back to Top