RadGrid control does not fire Update event
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"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
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"
/>
<
Columns
>
<
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"
/>
</
Columns
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
></
RowIndicatorColumn
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
</
mastertableview
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:radgrid
>
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;
Grid.DataBind();
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");
try
// 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
dynamicModuleManager.SaveChanges();
catch (Exception ex)
// 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;
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
Regards,
Kaloyan
Telerik