RadGrid UpdateCommand doesn't fire inside SimpleView

Posted by Community Admin on 04-Aug-2018 02:59

RadGrid UpdateCommand doesn't fire inside SimpleView

All Replies

Posted by Community Admin on 13-Mar-2012 00:00

I've been struggling with something that should take no more than 5 minutes, but has consumed hours by now.  I've even gone back and created everything from scratch, hence the funny names below...

I have the following control implemented inside a sitefinity module (sitefinity v4.4) :

public class Bob
    public int Id get; set;
    public string Description get; set;
public class TestGridView : SimpleView
    private string layoutTemplateName = "TestGridView.ascx";
    protected override string LayoutTemplateName get return layoutTemplateName;
 
    protected virtual RadGrid Grid get return this.Container.GetControl<RadGrid>("uxECGrid", true);
 
    protected override void InitializeControls(GenericContainer controlContainer)
    
        Grid.NeedDataSource += new GridNeedDataSourceEventHandler(Grid_NeedDataSource);
        Grid.UpdateCommand += new GridCommandEventHandler(Grid_UpdateCommand);
        Grid.DeleteCommand += new GridCommandEventHandler(Grid_DeleteCommand);
        Grid.EditCommand += new GridCommandEventHandler(Grid_EditCommand);
    
 
    void Grid_EditCommand(object sender, GridCommandEventArgs e)
    
         
    
 
    void Grid_DeleteCommand(object sender, GridCommandEventArgs e)
    
         
    
 
    void Grid_UpdateCommand(object sender, GridCommandEventArgs e)
    
         
    
 
    void Grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    
        List<Bob> items = new List<Bob>();
        items.Add(new Bob Id = 1, Description = "desc1" );
        items.Add(new Bob Id = 2, Description = "desc2" );
        Grid.DataSource = items;
    

Markup :

<%@ Control Language="C#" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<link rel="stylesheet" type="text/css" href="/Css/Admin.css" />
<h1 class="sfBreadCrumb" id="sfToMainContent">Test Grid View</h1>
<div class="sfMain sfWorkArea sfClearfix">
    <telerik:RadGrid runat="server" Width="100%" ID="uxECGrid" AutoGenerateColumns="False" DataKeyNames="Id" CellSpacing="0">
        <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" DataKeyNames="Id" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="Inplace">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" />
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" />
              <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px"
          ConfirmDialogWidth="220px" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" />
</div>

So, the UpdateCommand and InsertCommand events never fire, but EditCommand and DeleteCommand does (with the correct DataItems).  I've looked at the ItemCommand event and those Commands (PerformInsert, Update) never fires.

The page the control is hosted on is basically an empty sitefinity backend page (hence the sfBreadCrumb) etc.  Had the same problem with the default asp.net gridview, but I'm 100% it should work, because all the other controls implemented in the same way (with asp.net gridview) works.

Can anyone see something wrong here?

Update : I've now tried to move this to a standard user control instead of in a module and just sticking it on a backend page template (or a normal frontend page).  Same thing.  The grid works perfectly, except for firing the UpdateCommand and InsertCommand events.

Posted by Community Admin on 14-Mar-2012 00:00

I solved this eventually, and I'm posting the solution because I KNOW this will help people at some time.

When you create the page in Sitefinity,  make sure to "Enable ViewState" and "Include RadScriptManager", this is on he "Title & Properties" screen for the page.

Simple as that...  Days later :(

Posted by Community Admin on 11-Apr-2012 00:00

Works like a charm!!!
Thanks a lot... 

Posted by Community Admin on 04-May-2012 00:00

I upgraded a site to the latest version and found that three pages (out of all the pages) ended up with "Include RadScriptManager" unchecked. I checked these on the three pages, saved and republished the pages. But once I logout and log back in, the Include RadScriptManager button goes back to unchecked in the title and properties of the three pages. I believe that this button being unchecked causes the javascript errors that I see on the site when I go to any of the three pages.

Does anyone know why the button is not remaining checked when I log out of the backend?

Thanks,
Bolade

Posted by Community Admin on 09-Aug-2012 00:00

Thank you Dawid, Instead of "Days Later" it was only hours for me.

JT

This thread is closed