Unable to delete or update ASP GridView

centem
centem used Ask the Experts™
on
Please help. Why won't this gridview delete when I click on the delete button or update when I click on the update button. Below is the entire gridview code.
 
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
             AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="id"
             DataSourceID="SqlDataSource1">
             <Columns>
                 <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                 <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
                     ReadOnly="True" SortExpression="id" Visible="False" />
                 <asp:BoundField DataField="Userid" HeaderText="Userid" ReadOnly="True"
                     SortExpression="Userid" />
                 <asp:BoundField DataField="FirstN" HeaderText="FirstN" ReadOnly="True"
                     SortExpression="FirstN" />
                 <asp:BoundField DataField="LastN" HeaderText="LastN" ReadOnly="True"
                     SortExpression="LastN" />
                 <asp:BoundField DataField="MiddleI" HeaderText="MiddleI" ReadOnly="True"
                     SortExpression="MiddleI" />
                 <asp:BoundField DataField="Location" HeaderText="Location" ReadOnly="True"
                     SortExpression="Location" />
                 <asp:BoundField DataField="IACertificationDate"
                     HeaderText="IACertificationDate" SortExpression="IACertificationDate" />
             </Columns>
         </asp:GridView>
         <asp:SqlDataSource ID="SqlDataSource1" runat="server"
             ConflictDetection="CompareAllValues"
             ConnectionString="<%$ ConnectionStrings:nodiiguard_u2kdbConnectionString %>"
             DeleteCommand="DELETE FROM [U2K_UserList] WHERE [id] = @original_id AND (([Userid] = @original_Userid) OR ([Userid] IS NULL AND @original_Userid IS NULL)) AND (([FirstN] = @original_FirstN) OR ([FirstN] IS NULL AND @original_FirstN IS NULL)) AND (([LastN] = @original_LastN) OR ([LastN] IS NULL AND @original_LastN IS NULL)) AND (([MiddleI] = @original_MiddleI) OR ([MiddleI] IS NULL AND @original_MiddleI IS NULL)) AND (([Location] = @original_Location) OR ([Location] IS NULL AND @original_Location IS NULL)) AND (([IACertificationDate] = @original_IACertificationDate) OR ([IACertificationDate] IS NULL AND @original_IACertificationDate IS NULL))"
             InsertCommand="INSERT INTO [U2K_UserList] ([Userid], [FirstN], [LastN], [MiddleI], [Location], [IACertificationDate]) VALUES (@Userid, @FirstN, @LastN, @MiddleI, @Location, @IACertificationDate)"
             OldValuesParameterFormatString="original_{0}"
             SelectCommand="SELECT [id], [Userid], [FirstN], [LastN], [MiddleI], [Location], [IACertificationDate] FROM [U2K_UserList]"
             UpdateCommand="UPDATE [U2K_UserList] SET [Userid] = @Userid, [FirstN] = @FirstN, [LastN] = @LastN, [MiddleI] = @MiddleI, [Location] = @Location, [IACertificationDate] = @IACertificationDate WHERE [id] = @original_id AND (([Userid] = @original_Userid) OR ([Userid] IS NULL AND @original_Userid IS NULL)) AND (([FirstN] = @original_FirstN) OR ([FirstN] IS NULL AND @original_FirstN IS NULL)) AND (([LastN] = @original_LastN) OR ([LastN] IS NULL AND @original_LastN IS NULL)) AND (([MiddleI] = @original_MiddleI) OR ([MiddleI] IS NULL AND @original_MiddleI IS NULL)) AND (([Location] = @original_Location) OR ([Location] IS NULL AND @original_Location IS NULL)) AND (([IACertificationDate] = @original_IACertificationDate) OR ([IACertificationDate] IS NULL AND @original_IACertificationDate IS NULL))">
             <DeleteParameters>
                 <asp:Parameter Name="original_id" Type="Int32" />
                 <asp:Parameter Name="original_Userid" Type="String" />
                 <asp:Parameter Name="original_FirstN" Type="String" />
                 <asp:Parameter Name="original_LastN" Type="String" />
                 <asp:Parameter Name="original_MiddleI" Type="String" />
                 <asp:Parameter Name="original_Location" Type="String" />
                 <asp:Parameter Name="original_IACertificationDate" Type="DateTime" />
             </DeleteParameters>
             <InsertParameters>
                 <asp:Parameter Name="Userid" Type="String" />
                 <asp:Parameter Name="FirstN" Type="String" />
                 <asp:Parameter Name="LastN" Type="String" />
                 <asp:Parameter Name="MiddleI" Type="String" />
                 <asp:Parameter Name="Location" Type="String" />
                 <asp:Parameter Name="IACertificationDate" Type="DateTime" />
             </InsertParameters>
             <UpdateParameters>
                 <asp:Parameter Name="Userid" Type="String" />
                 <asp:Parameter Name="FirstN" Type="String" />
                 <asp:Parameter Name="LastN" Type="String" />
                 <asp:Parameter Name="MiddleI" Type="String" />
                 <asp:Parameter Name="Location" Type="String" />
                 <asp:Parameter Name="IACertificationDate" Type="DateTime" />
                 <asp:Parameter Name="original_id" Type="Int32" />
                 <asp:Parameter Name="original_Userid" Type="String" />
                 <asp:Parameter Name="original_FirstN" Type="String" />
                 <asp:Parameter Name="original_LastN" Type="String" />
                 <asp:Parameter Name="original_MiddleI" Type="String" />
                 <asp:Parameter Name="original_Location" Type="String" />
                 <asp:Parameter Name="original_IACertificationDate" Type="DateTime" />
             </UpdateParameters>
         </asp:SqlDataSource>

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You dnt have delete parameters.

And why are you not deleting/ updating  the row just by id? What is the need for that big where clause?

Thanks
GlobaLevelProgrammer
Commented:
why not use the wizard off the tool box for gridview...click on the smart tag...else should like this:
<%@ Page Language="VB" %>
<html>
  <head runat="server">
    <title>Updating Data Using GridView</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" Runat="server"
        DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="au_id"
        AutoGenerateColumns="False">
        <Columns>
          <asp:BoundField ReadOnly="true" HeaderText="ID" DataField="au_id" SortExpression="au_id" />
          <asp:BoundField HeaderText="Last Name" DataField="au_lname" SortExpression="au_lname" />
          <asp:BoundField HeaderText="First Name" DataField="au_fname" SortExpression="au_fname" />
          <asp:BoundField HeaderText="Phone" DataField="phone" SortExpression="phone" />
          <asp:BoundField HeaderText="Address" DataField="address" SortExpression="address" />
          <asp:BoundField HeaderText="City" DataField="city" SortExpression="city" />
          <asp:BoundField HeaderText="State" DataField="state" SortExpression="state" />
          <asp:BoundField HeaderText="Zip Code" DataField="zip" SortExpression="zip" />
          <asp:CheckBoxField HeaderText="Contract" SortExpression="contract" DataField="contract" />
        </Columns>
      </asp:GridView>
      <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT [au_id], [au_lname], [au_fname], [phone], [address], [city], [state], [zip], [contract] FROM [authors]"
        UpdateCommand="UPDATE [authors] SET [au_lname] = @au_lname, [au_fname] = @au_fname, [phone] = @phone, [address] = @address, [city] = @city, [state] = @state, [zip] = @zip, [contract] = @contract WHERE [au_id] = @au_id"
        ConnectionString="<%$ ConnectionStrings:Pubs %>" />
    </form>
  </body>
</html>

Open in new window

Commented:
I used the GridView wizard. Connection to DB works, permissions are good. The wierd thing is that it was working with no problem and then the delete and update stop working. I recreated the entire thing from scratch but still cannot do delete or update. I'm using Visual Web 2010 Express. Is there someting bugy with the IDE. I didn't find any known issues online.

Author

Commented:
Problem did not get fixed but will move on to other pending things.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial