More in this section

Forums / Developing with Sitefinity / RadGrid UpdateCommand doesn't fire inside SimpleView

RadGrid UpdateCommand doesn't fire inside SimpleView

5 posts, 0 answered
  1. Dawid
    Dawid avatar
    15 posts
    Registered:
    30 Jan 2012
    13 Mar 2012
    Link to this post
    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.

  2. Dawid
    Dawid avatar
    15 posts
    Registered:
    30 Jan 2012
    14 Mar 2012
    Link to this post
    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 :(
  3. Guillermo
    Guillermo  avatar
    9 posts
    Registered:
    17 Feb 2012
    11 Apr 2012
    Link to this post
    Works like a charm!!!
    Thanks a lot... 
  4. Bolade
    Bolade avatar
    5 posts
    Registered:
    04 Apr 2012
    04 May 2012
    Link to this post
    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
  5. JT
    JT avatar
    4 posts
    Registered:
    14 Feb 2011
    09 Aug 2012
    Link to this post
    Thank you Dawid, Instead of "Days Later" it was only hours for me.

    JT
5 posts, 0 answered