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

Delete Confirmation

1 Answer 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BRK
Top achievements
Rank 1
BRK asked on 12 Nov 2011, 07:49 AM
Hi All,

I have generated a RadGrid using a table. Code below is
While delete I need confirmation.
For that I have added confirmationtext usingtelerik:GridButtonColumn But it is not deleting. Only it is howing a message box. So what code we need to put in code-behind or aspx page to do deletions. Tell me some suggestions

<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True"             
            ShowStatusBar="True" AllowPaging="True" Skin="Office2007"
            AutoGenerateDeleteColumn="True" AutoGenerateColumns="False" AllowFilteringByColumn="True"
            DataSourceID="SqlDataSource5" GridLines="None" Width="520px"
AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AutoGenerateEditColumn="True">
             
            <MasterTableView DataSourceID="SqlDataSource5" AllowAutomaticUpdates="True"
                 CommandItemDisplay="Top"  DataKeyNames="ID" AllowAutomaticInserts="true">
                 
                <Columns>               
                    <telerik:GridBoundColumn DataField="ID" HeaderText="ID" SortExpression="ID"
                        UniqueName="ID" DataType="System.Int32" ReadOnly="True" Visible="false"  />
                    <telerik:GridBoundColumn DataField="Class" HeaderText="Class" SortExpression="Class"
                        UniqueName="Class" />                   
                    <telerik:GridBoundColumn DataField="Course"
                        HeaderText="Course" SortExpression="Course" UniqueName="Course" AllowFiltering="false">
                    </telerik:GridBoundColumn
                     
                    <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this row or record?"
                    CommandName="Delete" Text="Delete">
</telerik:GridButtonColumn>
 
                     
                        
                    <%--<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>--%>
     
                </Columns>
            </MasterTableView>
                    <HeaderStyle HorizontalAlign="Center" />
        </telerik:RadGrid>
         
                    <asp:SqlDataSource ID="SqlDataSource5" runat="server"
                        ConnectionString="<%$ ConnectionStrings:SearchingConnectionString %>"
                        DeleteCommand="DELETE FROM [Clas_Course] WHERE [ID] = @ID"
                        InsertCommand="INSERT INTO [Clas_Course] ([Class], [Course]) VALUES (@Class, @Course)"
                        SelectCommand="SELECT [ID], [Class], [Course] FROM [Clas_Course]"
                        UpdateCommand="UPDATE [Clas_Course] SET [Class] = @Class, [Course] = @Course WHERE [ID] = @ID">
                        <DeleteParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>                       
                            <asp:Parameter Name="Class" Type="String" />
                            <asp:Parameter Name="Course" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="Class" Type="String" />
                            <asp:Parameter Name="Course" Type="String" />
                            <asp:Parameter Name="ID" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td></tr>
                 </table>   <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
                    </div
        <div class="cornerDiv">
            <img src="Images/bLeft_corner.gif" class="float"/>
            <div class="bg_div"></div>
            <img src="Images/bRight_corner.gif" class="float"/>
        </div>

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Nov 2011, 05:27 AM
Hello Brk,

In order to implement automatic datasource operations, make sure that you have set AllowAutomaticDeletes as true. Also check the following demo which implements the same.
Grid / Automatic Operations

-Shinu.
Tags
Grid
Asked by
BRK
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or