More in this section

Forums / Developing with Sitefinity / RadGrid control does not fire Update event

RadGrid control does not fire Update event

2 posts, 0 answered
  1. Michael
    Michael avatar
    13 posts
    25 Aug 2008
    30 Sep 2013
    Link to this post
    I am using a RadGrid control on a custom widget page.  I can successfully bind data to a Dynamic Module, but the UpdateCommand event does not fire and am unable to update any changes made to
    the grid after edit.  I have enabled ViewState and RadScriptManager for the page hosting the widget.  EditCommand fires, but not UpdateCommand.   Any suggestions?

    1.      Create new custom wizard using Thunder.

    2.      Add RadGrid control to ascx page.

    3.      Data bind control during InitializeControls

    4.      Registered events for RadGrid control 

    5.      The EditCommand control will fire, but not the RadGrid1_UpdateCommand  

    6.      The page where the widget has been added has ViewState and RadScriptManager checked.

    <telerik:radgrid id="RadGrid1" runat="server" Skin="Black" >
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        <mastertableview EditMode="InPlace" CommandItemDisplay="TopAndBottom" AutoGenerateColumns="False" DataKeyNames="ID" AllowAutomaticInserts="true">
            <EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit Item: {0}" CaptionDataField="ID" PopUpSettings-Modal="true" />
         <telerik:GridBoundColumn HeaderText="Title" DataField="Title" UniqueName="Title"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="Location" DataField="Location" UniqueName="Location"></telerik:GridBoundColumn>
         <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
         <telerik:GridButtonColumn CommandName="Delete" Text="Delete" HeaderText="Delete" UniqueName= "DeleteColumn" />
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    <FilterMenu EnableImageSprites="False"></FilterMenu>

    Init Controls 

    protected override void InitializeControls(GenericContainer container)
              RadGrid Grid = this.Container.GetControl<RadGrid>("RadGrid1", true);
              Grid.UpdateCommand += new GridCommandEventHandler(RadGrid1_UpdateCommand);
              Grid.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
              Grid.UpdateCommand += new GridCommandEventHandler(RadGrid1_UpdateCommand);
              Grid.DeleteCommand += new GridCommandEventHandler(RadGrid1_DeleteCommand);
              Grid.EditCommand += new GridCommandEventHandler(RadGrid1_EditCommand);
              // Fetch a collection of "live" and "visible" project items.
              var myCollection = GetDataItems();
              // Binds the collection of Person items to the RadGrid
              Grid.DataSource = myCollection;


    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
                //Get the GridEditableItem of the RadGrid    
                GridEditableItem editedItem = e.Item as GridEditableItem;
                //Get the primary key value using the DataKeyValue.    
                Guid projectID = (Guid)editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"];
                //Access the textbox from the edit form template and store the values in string variables.    
                Hashtable newValues = new Hashtable();
                e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
                // Set the provider name for the DynamicModuleManager here. All available providers are listed in
                // Administration -> Settings -> Advanced -> DynamicModules -> Providers
                var providerName = String.Empty;
                DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
                Type projectType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.BugTracking.Project");
                    // This is how we get the project item by ID
                    DynamicContent projectItem = dynamicModuleManager.GetDataItem(projectType, projectID);
                    // This is how values for the properties are set
                    projectItem.SetValue("Title", newValues["Title"]);
                    projectItem.SetValue("Description", newValues["Description"]);
                    projectItem.SetValue("PublicationDate", DateTime.Now);
                    // You need to call SaveChanges() in order for the items to be actually persisted to data store
                catch (Exception ex)

    Get Collection 

    // Gets a collection of "live" and "visible" project items.
          public IQueryable<DynamicContent> GetDataItems()
              DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
              Type projectType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.BugTracking.Project");
              // Fetch a collection of "live" and "visible" project items.
              var myCollection = dynamicModuleManager.GetDataItems(projectType)
                  .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
              return myCollection;

    I based my code on the following example:
  2. Kaloyan
    Kaloyan avatar
    272 posts
    06 Feb 2017
    03 Oct 2013
    Link to this post
    Hi Michael,

    The blog post which you are using for reference is a bit old and it is suitable for 3.x projects.  My suggestion is to check the following forum threads where you can find some information which could be useful for you.

    RadGrid control add, edit, refresh and delete. Works on a page, but not on a backend page?

    Radgrid export in Custom Control

    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered