This is a migrated thread and some comments may be shown as answers.

PerformInsert and Update never fired

5 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roy Halvorsen
Top achievements
Rank 1
Roy Halvorsen asked on 30 Oct 2008, 01:43 PM
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>

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Oct 2008, 01:46 PM
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.
0
Roy Halvorsen
Top achievements
Rank 1
answered on 30 Oct 2008, 01:52 PM
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.
0
Accepted
Vlad
Telerik team
answered on 30 Oct 2008, 02:39 PM
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.
0
Roy Halvorsen
Top achievements
Rank 1
answered on 30 Oct 2008, 02:46 PM
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 !!
0
Eric Skaggs
Top achievements
Rank 2
answered on 14 Nov 2008, 09:33 PM
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.
Tags
Grid
Asked by
Roy Halvorsen
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Roy Halvorsen
Top achievements
Rank 1
Eric Skaggs
Top achievements
Rank 2
Share this question
or