delete command dosn't work!

2 posts, 0 answers
  1. mastermehdi
    mastermehdi avatar
    39 posts
    Member since:
    Apr 2010

    Posted 22 May 2011 Link to this post


    I can not delete rows in RadGrid

    any body can help me?

    my database code is:

    CREATE TABLE [test](
        [c1] [int] IDENTITY(1,1) NOT NULL CONSTRAINT [PK_test] PRIMARY KEY,
        [c2] [nvarchar](50) NULL,
    insert [test]
        ('aaa'), ('bbb'), ('ccc'), ('ddd'), ('eee')

    my aspx code is:

    <%@ Page Language="C#" %>
    <!DOCTYPE html>
    <head runat="server">
        <form id="form1" runat="server">
            <tlk:RadScriptManager ID="RadScriptManager1" runat="server" />
            <tlk:RadGrid ID="RadGrid1" runat="server" AutoGenerateDeleteColumn="True" DataSourceID="data">
                <MasterTableView DataSourceID="data" DataKeyNames="c1">
            <asp:SqlDataSource ID="data" runat="server"
                ConnectionString="<%$ ConnectionStrings:database %>" 
                ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [test]"
                DeleteCommand="DELETE FROM [test] WHERE [c1] = @c1">
                    <asp:Parameter Name="c1" Type="Int32" />

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 May 2011 Link to this post


     In order enable automatic deletion, you need to set the AllowAutomaticDeletes="True"

    Also check out the following help article for more on Automatic operations.
    Automatic DataSource operations

Back to Top