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

Deleting: Incorrect syntax near '?'

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Craig Smith
Top achievements
Rank 1
Craig Smith asked on 02 Oct 2009, 05:09 PM
Not sure how to set the delete command dynamically. Here is the code...


<telerik:RadGrid AutoGenerateColumns="False" ID="RADGRIDUnread" DataSourceID="SqlDataSource1" 
            Width="760px" AllowFilteringByColumn="True" AllowSorting="True" 
            PageSize="15" ShowStatusBar="True" ShowFooter="True" AllowPaging="True" runat="server" 
            GridLines="None" EnableLinqExpressions="False" AutoGenerateDeleteColumn="True"  
                    Skin="Sunset" AllowAutomaticDeletes="True" ShowGroupPanel="True"
            <PagerStyle Mode="NextPrevAndNumeric" /> 
            <GroupingSettings CaseSensitive="false" /> 
            <MasterTableView OnSelectedIndexChanged="Test" AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True" DataKeyNames="MessageID" 
                ShowFooter="True" TableLayout="Auto"
                <Columns> 
                    <telerik:GridBoundColumn DataField="MessageID" Display="false" UniqueName="MessageID"></telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn FilterControlWidth="100px" DataField="MessageSubject" HeaderText="Subject" SortExpression="MessageSubject" UniqueName="MessageSubject"></telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn FilterControlWidth="100px" DataField="FromName" HeaderText="From" SortExpression="FromName" UniqueName="FromName"></telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn FilterControlWidth="100px" DataField="MessageDate" HeaderText="Sent" SortExpression="MessageDate" UniqueName="MessageDate"></telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
            <ClientSettings AllowDragToGroup="True"
                <Selecting AllowRowSelect="True" /> 
            </ClientSettings> 
        </telerik:RadGrid> 
                 
                <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:AbsorbConnectionString %>" 
            ProviderName="System.Data.SqlClient" runat="server"
         
        <DeleteParameters> 
                <asp:Parameter Name="MessageID" Type="Int32" /> 
            </DeleteParameters> 
         
        </asp:SqlDataSource>

And the codebehind...

string sSQLDelete = "delete from messages where MessageID = ?"
 
SqlDataSource1.DeleteCommand = sSQLDelete; 

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Oct 2009, 08:18 AM
Hi Craig,

You should define desired delete command and add desired parameters for this. More info you can find here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.deletecommand.aspx

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Craig Smith
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or