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

Radgrid delete of row doesn't work

2 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tal
Top achievements
Rank 1
Tal asked on 14 Aug 2013, 06:29 AM
Hi,
please help me with the following aspx radgrid that when I click the delete button it removes the row from the grid (visually) but not from the database. there is not postback, just client side deleteion
thank you!

  CodeBehind="seasonsList.aspx.cs" Inherits="RadControlsWebApp2.seasonsList" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdateInitiatorPanelsOnly="True">
    </telerik:RadAjaxManager>
    <p>
         </p>
    <asp:Panel ID="Panel2" runat="server" Height="91px" Style="margin-right: 243px; padding-right: 100px;"
        Width="750px">
        <div>
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="true"
                AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0"
                DataSourceID="SqlDataSource1" GridLines="None" Skin="Office2007">
                 
                <SortingSettings SortToolTip="לחץ כאן כדי למיין" />
                <ExportSettings>
                    <Pdf PageHeight="297mm" PageWidth="210mm" PaperSize="A4" />
                </ExportSettings>
                <ClientSettings>
                    <Selecting AllowRowSelect="True" />
                </ClientSettings>
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="seasonID" DataSourceID="SqlDataSource1">
                 
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText="ביטול" EditText="עריכה"
                            FilterControlAltText="Filter EditCommandColumn column" meta:resourceKey="GridEditCommandColumnResource1"
                            UpdateText="עדכון" EditImageUrl="Images/edit.png" HeaderStyle-BorderStyle=None>
                        </telerik:GridEditCommandColumn>
                        <telerik:GridClientDeleteColumn ButtonType="ImageButton" ConfirmText="האם אתה בטוח שברצונך למחוק?"
                        Display="true" ImageUrl="Images/delete.gif" HeaderStyle-BorderStyle=None ConfirmTitle="מחיקה">
                         
                        </telerik:GridClientDeleteColumn>
                        <telerik:GridBoundColumn DataField="seasonID" DataType="System.Int32" FilterControlAltText="Filter seasonID column"
                            HeaderText="קוד עונה" ReadOnly="true" SortExpression="seasonID" UniqueName="seasonID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="seasonName" FilterControlAltText="Filter seasonName column"
                            HeaderText="שם עונה" SortExpression="seasonName" UniqueName="seasonName">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                </MasterTableView>
                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
            </telerik:RadGrid>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tm2013ConnectionString %>"
                DeleteCommand="DELETE FROM [tblseasons] where [seasonID]=@seasonID"
                UpdateCommand="UPDATE [tblseasons] SET [seasonName]=@seasonName where [seasonID]=@seasonID"
                SelectCommand="SELECT [seasonID], [seasonName] FROM [tblseasons]">
                <DeleteParameters>
                    <asp:Parameter Name="seasonID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="seasonName" Type="String" />
                    <asp:Parameter Name="seasonID" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
        <telerik:RadButton ID="addNewSeason_btn" runat="server" Text="הוסף עונה חדשה" OnClick="addNewSeason_Click">
        </telerik:RadButton>
               
    </asp:Panel>
    </asp:Panel>
</asp:Content>

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Aug 2013, 07:25 AM
Hi Tal,

GridClientDeleteColumn is designed to delete rows client-side and to persist these changes. Once you post your page to the server the grid will delete client deleted rows. If you want immediate delete with post-back you can use GridButtonColumn with CommandName = "Delete".

Check this demo on GridClientDeleteColumn for more information.

Thanks,
Princy
0
Tal
Top achievements
Rank 1
answered on 14 Aug 2013, 08:35 AM
Hi Princy,
thank you for your quick reply.

Tags
Grid
Asked by
Tal
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Tal
Top achievements
Rank 1
Share this question
or