We help IT Professionals succeed at work.
Get Started

Unable to delete or update ASP GridView

centem
centem asked
on
473 Views
Last Modified: 2012-05-11
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
Commented:
This problem has been solved!
Unlock 3 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE