Double entry on insert

6 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 26 Feb 2009 Link to this post

    Hi All

    Why does my gridview insert 2 records on insert. Its not just the insert, I was testing the control values by writing to a literalControl, and this showed twice.

    I'm using a data class to fill and form template editing.

    Any Ideas. here is my grid code: (I actually have a nested grid but I've taken that portion out to save space - could that be the problem?














                 OnDeleteCommand="rgRisk_DeleteCommand" >


                   <MasterTableView GridLines="Horizontal" CommandItemDisplay="Top" DataKeyNames="Risk_Area_ID" Width="100%" NoMasterRecordsText="No Risk Areas" NoDetailRecordsText="No Risks Identified" >





                           <telerik:GridEditCommandColumn CancelImageUrl="../App_Themes/Expert/Grid/Cancel.gif" EditImageUrl="../App_Themes/Expert/Grid/Edit.gif" InsertImageUrl="../App_Themes/Expert/Grid/Update.gif" UpdateImageUrl="../App_Themes/Expert/Grid/Update.gif" ButtonType="ImageButton"><HeaderStyle Width="15px" /><ItemStyle Width="15px" /></telerik:GridEditCommandColumn>


                           <telerik:GridBoundColumn DataField="Risk_Area" EmptyDataText="&amp;nbsp;" HeaderText="Risk Area" ></telerik:GridBoundColumn>


                           <telerik:GridExpandColumn><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridExpandColumn>


                           <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete" ImageUrl="../App_Themes/Expert/Grid/delete.gif" UniqueName="column"><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridButtonColumn>




                        <EditFormSettings EditFormType="Template">


                            <EditColumn UniqueName="EditCommandColumn1"> </EditColumn>


                            <EditColumn CancelImageUrl="../App_Themes/Expert/Grid/Cancel.gif" EditImageUrl="../App_Themes/Expert/Grid/Edit.gif" InsertImageUrl="../App_Themes/Expert/Grid/Update.gif" UpdateImageUrl="../App_Themes/Expert/Grid/Update.gif" ButtonType="ImageButton" ></EditColumn>



                                        <label class="gridlabel">Risk Area / Room:</label><telerik:RadTextBox ID="txtRiskArea" runat="server" Width="300px" Text='<%# Eval( "Risk_Area" ) %>' CssClass="gridtext"></telerik:RadTextBox>



                                        <asp:Button ID="btnUpdate" cssclass="gridbtn" Text='<%#iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "Insert","Update")  %>' runat="server" CommandName='<%# iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert", "Update" )%>'></asp:Button> 

                                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" cssclass="gridbtn" CommandName="Cancel"/>  





                       <CommandItemSettings AddNewRecordText="Add new area" /><RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn>




                   <FilterMenu EnableEmbeddedSkins="False" EnableTheming="True" Skin="Expert"><CollapseAnimation Duration="200" Type="OutQuint" /></FilterMenu>



  2. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 27 Feb 2009 Link to this post

    A Thought

    I have 2 nested grids - but in my insert code I'm not differentiating between which one is doing the update (I've not looked at the second one yet), so could it be that the insert in running once for each grid?

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 01 Mar 2009 Link to this post

    Its not a 2 nested grid issue, I've checked the grid I want to update ad only run code for that grid, and I have 2 updates, in desperation I deleted the nested grid, and it sill does it.

    Msut be a on postack / page load problem I think.

    Does anyone have any ideas.

  5. Answer
    Sebastian avatar
    9934 posts

    Posted 02 Mar 2009 Link to this post

    Hello Andy,

    Is it possible that you are writing in VB.NET language and attached the event handlers for the grid twice (once declarative in the markup and once with Handles clause in the code-behind)? This can result in duplicate event firing in your case.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 04 Mar 2009 Link to this post

    Spot on thank you.

    I had the following in my radgrid




  7. Pam
    Pam avatar
    10 posts
    Member since:
    Sep 2012

    Posted 24 Jan 2013 Link to this post

    This thread was very helpful and very simple to understand. I encountered the same situation and it was a good lesson for me not to put both a handler on code behind and on markup.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017