PerformInsert and Update never fired

6 posts, 1 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 30 Oct 2008 Link to this post

    I have a grid in a usercontrol. All events in the grid works, except for PerformInsert and Update commands. Those two commands never fires. I have looked at all the examples, tried different solutions, but no matter what I do, the events never fires. All they do is closing the editform. I have tried with LinqDataSource, and NeedDataSource in codebehind. Here is my Grid:

    <code>
                <telerik:RadGrid ID="rgBestander"
                    runat="server"
                    AllowSorting="true"
                    AllowPaging="true"
                    PageSize="20"
                    AutoGenerateColumns="false"
                    ClientSettings-EnableRowHoverStyle="true"
                    GridLines="none"
                    Skin="WebBlue"
                    Width="97%"
                    PagerStyle-Mode="NextPrevAndNumeric"
                    PagerStyle-NextPagesToolTip="Neste side"
                    PagerStyle-NextPageText="Neste >>"
                    Pagerstyle-NextPageToolTip="Neste side"
                    PagerStyle-PrevPagesToolTip="Forrige side"
                    PagerStyle-PrevPageText="<< Forrige"
                    PagerStyle-PrevPageToolTip="Forrige side"
                    PagerStyle-ShowPagerText="false"
                    OnItemCommand="rgBestander_ItemCommand"
                    OnInsertCommand="rgBestander_InsertCommand"
                    OnUpdateCommand="rgBestander_UpdateCommand"
                    OnNeedDataSource="rgBestander_NeedDataSource">
                    <MasterTableView DataKeyNames="Id"
                        Width="100%"
                        CommandItemDisplay="Top"
                        CommandItemSettings-AddNewRecordText="Legg til ny bestand"
                        CommandItemSettings-RefreshText="Oppdater"
                        NoMasterRecordsText="Ingen data å vise ...">
                        <Columns>
                            <telerik:GridBoundColumn DataField="Id" SortExpression="Id" HeaderText="&nbsp;BestandID" ReadOnly="true" HeaderButtonType="TextButton" ItemStyle-Width="100" HeaderStyle-Width="100" />
                            <telerik:GridBoundColumn DataField="BestandNavn" SortExpression="BestandNavn" HeaderText="&nbsp;Bestand" />
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText="Avbryt" EditText="Oppdater" InsertText="Lagre" ItemStyle-HorizontalAlign="Right" />
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                <table border="0" cellpadding="2" cellspacing="0">
                                    <tr>
                                        <td><asp:Label ID="lblBestandID" runat="server" Text="BestandID" /></td>
                                        <td><asp:TextBox ID="txtBestandID" runat="server" Text='<%# Eval( "Id") %>' CssClass="tekstfelt" style="width:100px" ReadOnly="true" /></td>
                                    </tr>
                                    <tr>
                                        <td><asp:Label ID="lblBestandNavn" runat="server" Text="Bestand navn" /></td>
                                        <td><asp:TextBox ID="txtBestandNavn" runat="server" Text='<%# Eval( "BestandNavn") %>' CssClass="tekstfelt" style="width:500px" /></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td><asp:Button ID="btnLagre" Text='<%#  (Container as GridItem).OwnerTableView.IsItemInserted ? "Legg til" : "Oppdater" %>' runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>' CssClass="logginnknapp" /><asp:Button ID="btnAvbryt" Text="Avbryt" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="logginnknapp" /></td>
                                    </tr>
                                </table>
                            </FormTemplate>
                        </EditFormSettings>
                    </MasterTableView>
                </telerik:RadGrid>
    </code>

    And here is the codebehind:
    <code>

            protected void rgBestander_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
            {
                var ds = Repository.getCurrent().HentAlleBestander();
                rgBestander.DataSource = ds.ToList();
            }

            protected void rgBestander_InsertCommand(object source, GridCommandEventArgs e)
            {
       var thisMessage = "Hello world";
            }
    </code>

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Oct 2008 Link to this post

    Hello Roy

    Automatic operations are supported only when the grid is bound via DataSourceID. Please check this code library for more info:
    http://www.telerik.com/community/code-library/submission/b311D-bcmcht.aspx

    All the best,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 30 Oct 2008 Link to this post

    Thanks for your example code, but I am not using automatic operations. I am using OnNeedDataSource where the grid gets it's data in codebehind, so your answer is not helping me here.
  5. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Oct 2008 Link to this post

    Hello Roy,

    Can you verify if the grid parent control(s) or page viewstate is on?

    Best wishes,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 30 Oct 2008 Link to this post

    ViewState was the problem. By default, the ContentPlaceHolder in the masterpage had EnableViewState to false. When setting it to true, it works. Thanks a lot !!
  7. Eric Skaggs
    Eric Skaggs avatar
    39 posts
    Member since:
    Nov 2008

    Posted 14 Nov 2008 Link to this post

    That solved it for me as well.  I'm using the RadGrid in a SharePoint application page and was unable to figure out why the UpdateCommand event was never firing.  Turns out that the viewstate was turned off in my .aspx page as well as the .master page.  Once I turned it on, the event fired as expected.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017