Delete Error

3 posts, 0 answers
  1. Dave
    Dave avatar
    11 posts
    Member since:
    Jul 2011

    Posted 26 Jul 2011 Link to this post

    I have placed a delete button in the ItemTemplate section and the AlternatingItemTemplate area.  When I try and click on the button, I get the following message

    You have specified that your delete command compares all values on SqlDataSource 'dsLTDist0', but the dictionary passed in for values is empty.  Pass in a valid dictionary for delete or change your mode to OverwriteChanges



    I have an update button in the same line and it seems to work correctly.  here is my datasource code....

    <asp:SqlDataSource ID="dsLTDist0" runat="server"
            ConflictDetection="CompareAllValues"
            ConnectionString="<%$ ConnectionStrings:Tech-InnovationsConnectionString %>"
            DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @original_ID"
            InsertCommand="INSERT INTO [Appointments] ([Subject], [Unit], [Area], [Vehicle], [Status], [Hours], [Comments],[Start],[End],[District]) VALUES (@Subject, @Unit, @Area, @Vehicle, @Status, @Hours, @Comments,@Start,@End,@District)"
            OldValuesParameterFormatString="original_{0}"
            SelectCommand="SELECT [ID], [Subject], [Unit], [Area], [Vehicle], [Status], [Hours], [Comments] FROM [Appointments]"
             
             
             
            UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Unit] = @Unit, [Area] = @Area, [Vehicle] = @Vehicle, [Status] = @Status, [Hours] = @Hours, [Comments] = @Comments WHERE [ID] = @original_ID AND [Subject] = @original_Subject AND (([Unit] = @original_Unit) OR ([Unit] IS NULL AND @original_Unit IS NULL)) AND (([Area] = @original_Area) OR ([Area] IS NULL AND @original_Area IS NULL)) AND (([Vehicle] = @original_Vehicle) OR ([Vehicle] IS NULL AND @original_Vehicle IS NULL)) AND (([Status] = @original_Status) OR ([Status] IS NULL AND @original_Status IS NULL)) AND (([Hours] = @original_Hours) OR ([Hours] IS NULL AND @original_Hours IS NULL)) AND (([Comments] = @original_Comments) OR ([Comments] IS NULL AND @original_Comments IS NULL))">
            <DeleteParameters>
                <asp:Parameter Name="original_ID" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Unit" Type="String" />
                <asp:Parameter Name="Area" Type="String" />
                <asp:Parameter Name="Vehicle" Type="String" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="Hours" Type="String" />
                <asp:Parameter Name="Comments" Type="String" />
                <asp:Parameter Name="Start" Type="datetime" />
                <asp:Parameter Name="End" Type="datetime" />
                <asp:Parameter Name="District" Type="int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Unit" Type="String" />
                <asp:Parameter Name="Area" Type="String" />
                <asp:Parameter Name="Vehicle" Type="String" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="Hours" Type="String" />
                <asp:Parameter Name="Comments" Type="String" />
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="original_Subject" Type="String" />
                <asp:Parameter Name="original_Unit" Type="String" />
                <asp:Parameter Name="original_Area" Type="String" />
                <asp:Parameter Name="original_Vehicle" Type="String" />
                <asp:Parameter Name="original_Status" Type="String" />
                <asp:Parameter Name="original_Hours" Type="String" />
                <asp:Parameter Name="original_Comments" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>

    and here is my ItemTemplate

    <ItemTemplate>
        <tr class="rlvI">
            <td>
                <asp:Button ID="EditButton" runat="server" CausesValidation="False"
                    CommandName="Edit" CssClass="rlvBEdit" Text=" " ToolTip="Edit" />
            </td>
            <td>
                <asp:Label ID="SubjectLabel" runat="server" width ="170" Text='<%# Eval("Subject") %>' />
            </td>
            <td>
                <asp:Label ID="UnitLabel" runat="server"  width ="70" Text='<%# Eval("Unit") %>' />
            </td>
            <td>
                <asp:Label ID="AreaLabel" runat="server"  width ="70" Text='<%# Eval("Area") %>' />
            </td>
            <td>
                <asp:Label ID="VehicleLabel" runat="server"  width ="70" Text='<%# Eval("Vehicle") %>' />
            </td>
            <td>
                <asp:Label ID="HoursLabel" runat="server"  width ="80" Text='<%# Eval("Hours") %>' />
            </td>
            <td>
                <asp:Label ID="StatusLabel" runat="server"  width ="100" Text='<%# Eval("Status") %>' />
            </td>
            <td>
                <asp:Label ID="CommentsLabel" runat="server"  width ="200" Text='<%# Eval("Comments") %>' />
            </td>
            <td>
                <asp:Button ID="btnDel" runat="server" CausesValidation="False"
                    CommandName="Delete" CssClass="rlvBDel" Text=" " ToolTip="Delete this Record" />
            </td>
     
        </tr>
    </ItemTemplate>

    Any ideas or Suggestions?
  2. Tsvetina
    Admin
    Tsvetina avatar
    1873 posts

    Posted 01 Aug 2011 Link to this post

    Hi Dave,

    I assume the problem is rather related to the SqlDataSource control itself and not to the listview. I would suggest you to try deleting an entry manually to confirm this.

    Additionally, you could take a look at these forum threads which address the same issue:
    http://forums.asp.net/t/1598557.aspx/1
    http://forums.asp.net/t/1137696.aspx/1

    All the best,
    Tsvetina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Zuhair
    Zuhair avatar
    1 posts
    Member since:
    Aug 2012

    Posted 23 Aug 2012 Link to this post

    Hi to all

    to solve this problem, its need to configure Advanced SQL Genration Options
    by remove the check box from (Use optimisitic concurrency)
    then the delete option will work.

    Best Regards
    Zuhair Al Saadi
    UAE
    ABu Dhabi
    zuhair_m_yousif@hotmail.com
Back to Top