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

delete command dosn't work!

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mastermehdi
Top achievements
Rank 2
mastermehdi asked on 22 May 2011, 06:02 AM

hi

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]
    ([c2])
values
    ('aaa'), ('bbb'), ('ccc'), ('ddd'), ('eee')

my aspx code is:

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

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 May 2011, 06:55 AM
Hello,

 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

Thanks,
Shinu.
Tags
Grid
Asked by
mastermehdi
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or