none
Asp.Net Gridview: Edit, Update, delete Not working RRS feed

  • Question

  • Hello,

    My edit, update, delete commands in my Visual Studio 2010 ASP.Net website project gridviews are not functioning.  I have to admit, I'm still beginner/intermediate to this ...

    I originally designed my database in Visual Studio 2005.  I then got SQL Server 2005, and tinkered with the database a bit, and used "script to" so that if I wanted to, I could recreate the database tables, scripts, etc.  I recently upgraded to Visual studio 2010, and used the project importer to save it as a Visual Studio 2010 project.

    I have seen a post indicating that 'Causes Validation = False' might solve it ... but it didn't.  Anyone have any other suggestions?

    here's the pertinent info:

    <asp:GridView ID="ContactsGridView" runat="server" DataSourceID="ContactsToCompaniesSQLDataSourceDocument" 
    
       Font-Size="X-Small" style="z-index: 1; left: 300px; top: 130px; position: absolute; height: 115px; width: 425px" 
    
       AutoGenerateColumns="False" DataKeyNames="ContsContactIDN" 
    
      PageSize="5" AllowPaging="True" AllowSorting="True">
    
       <Columns>
    
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
    
         CausesValidation="False" />
    
        <asp:BoundField DataField="ContsContactIDN" HeaderText="ContsContactIDN" 
    
         SortExpression="ContsContactIDN" InsertVisible="False" ReadOnly="True" />
    
        <asp:BoundField DataField="ContsCompanyIDN" 
    
         HeaderText="ContsCompanyIDN" 
    
         SortExpression="ContsCompanyIDN" />
    
        <asp:BoundField DataField="ContsContactFull" HeaderText="ContsContactFull" 
    
         SortExpression="ContsContactFull" />
    
        <asp:BoundField DataField="ContsMailAddr1" HeaderText="ContsMailAddr1" 
    
         SortExpression="ContsMailAddr1" />
    
        <asp:BoundField DataField="ContsPhysAddr1" HeaderText="ContsPhysAddr1" 
    
         SortExpression="ContsPhysAddr1" />
    
        <asp:BoundField DataField="ContsAltMailAddr" HeaderText="ContsAltMailAddr" 
    
         SortExpression="ContsAltMailAddr" />
    
        <asp:BoundField DataField="ContsHomeMailAddr1" HeaderText="ContsHomeMailAddr1" 
    
         SortExpression="ContsHomeMailAddr1" />
    
       </Columns>
    
      </asp:GridView>
    
    
    
       <asp:SqlDataSource ID="ContactsToCompaniesSQLDataSourceDocument" runat="server" 
    
       ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    
      SelectCommand="SELECT [ContsContactIDN], [ContsCompanyIDN], [ContsContactFull], [ContsMailAddr1], [ContsPhysAddr1], [ContsAltMailAddr], [ContsHomeMailAddr1] FROM [CompaniesContacts] WHERE ([ContsCompanyIDN] = @CompaniesWeKnowCWKClientIDN)" 
    
      ConflictDetection="CompareAllValues" 
    
      DeleteCommand="DELETE FROM [CompaniesContacts] WHERE [ContsContactIDN] = @original_ContsContactIDN AND (([ContsCompanyIDN] = @original_ContsCompanyIDN) OR ([ContsCompanyIDN] IS NULL AND @original_ContsCompanyIDN IS NULL)) AND (([ContsContactFull] = @original_ContsContactFull) OR ([ContsContactFull] IS NULL AND @original_ContsContactFull IS NULL)) AND (([ContsMailAddr1] = @original_ContsMailAddr1) OR ([ContsMailAddr1] IS NULL AND @original_ContsMailAddr1 IS NULL)) AND (([ContsPhysAddr1] = @original_ContsPhysAddr1) OR ([ContsPhysAddr1] IS NULL AND @original_ContsPhysAddr1 IS NULL)) AND (([ContsAltMailAddr] = @original_ContsAltMailAddr) OR ([ContsAltMailAddr] IS NULL AND @original_ContsAltMailAddr IS NULL)) AND (([ContsHomeMailAddr1] = @original_ContsHomeMailAddr1) OR ([ContsHomeMailAddr1] IS NULL AND @original_ContsHomeMailAddr1 IS NULL))" 
    
      InsertCommand="INSERT INTO [CompaniesContacts] ([ContsCompanyIDN], [ContsContactFull], [ContsMailAddr1], [ContsPhysAddr1], [ContsAltMailAddr], [ContsHomeMailAddr1]) VALUES (@ContsCompanyIDN, @ContsContactFull, @ContsMailAddr1, @ContsPhysAddr1, @ContsAltMailAddr, @ContsHomeMailAddr1)" 
    
      OldValuesParameterFormatString="original_{0}" 
    
      UpdateCommand="UPDATE [CompaniesContacts] SET [ContsCompanyIDN] = @ContsCompanyIDN, [ContsContactFull] = @ContsContactFull, [ContsMailAddr1] = @ContsMailAddr1, [ContsPhysAddr1] = @ContsPhysAddr1, [ContsAltMailAddr] = @ContsAltMailAddr, [ContsHomeMailAddr1] = @ContsHomeMailAddr1 WHERE [ContsContactIDN] = @original_ContsContactIDN AND (([ContsCompanyIDN] = @original_ContsCompanyIDN) OR ([ContsCompanyIDN] IS NULL AND @original_ContsCompanyIDN IS NULL)) AND (([ContsContactFull] = @original_ContsContactFull) OR ([ContsContactFull] IS NULL AND @original_ContsContactFull IS NULL)) AND (([ContsMailAddr1] = @original_ContsMailAddr1) OR ([ContsMailAddr1] IS NULL AND @original_ContsMailAddr1 IS NULL)) AND (([ContsPhysAddr1] = @original_ContsPhysAddr1) OR ([ContsPhysAddr1] IS NULL AND @original_ContsPhysAddr1 IS NULL)) AND (([ContsAltMailAddr] = @original_ContsAltMailAddr) OR ([ContsAltMailAddr] IS NULL AND @original_ContsAltMailAddr IS NULL)) AND (([ContsHomeMailAddr1] = @original_ContsHomeMailAddr1) OR ([ContsHomeMailAddr1] IS NULL AND @original_ContsHomeMailAddr1 IS NULL))">
    
        <DeleteParameters>
    
         <asp:Parameter Name="original_ContsContactIDN" Type="Int32" />
    
         <asp:Parameter Name="original_ContsCompanyIDN" Type="Decimal" />
    
         <asp:Parameter Name="original_ContsContactFull" Type="String" />
    
         <asp:Parameter Name="original_ContsMailAddr1" Type="String" />
    
         <asp:Parameter Name="original_ContsPhysAddr1" Type="String" />
    
         <asp:Parameter Name="original_ContsAltMailAddr" Type="String" />
    
         <asp:Parameter Name="original_ContsHomeMailAddr1" Type="String" />
    
        </DeleteParameters>
    
        <InsertParameters>
    
         <asp:Parameter Name="ContsCompanyIDN" Type="Decimal" />
    
         <asp:Parameter Name="ContsContactFull" Type="String" />
    
         <asp:Parameter Name="ContsMailAddr1" Type="String" />
    
         <asp:Parameter Name="ContsPhysAddr1" Type="String" />
    
         <asp:Parameter Name="ContsAltMailAddr" Type="String" />
    
         <asp:Parameter Name="ContsHomeMailAddr1" Type="String" />
    
        </InsertParameters>
    
       <SelectParameters>
    
        <asp:ProfileParameter Name="CompaniesWeKnowCWKClientIDN" PropertyName="CompaniesWeKnowCWKClientIDN" 
    
         Type="Decimal" />
    
       </SelectParameters>
    
        <UpdateParameters>
    
         <asp:Parameter Name="ContsCompanyIDN" Type="Decimal" />
    
         <asp:Parameter Name="ContsContactFull" Type="String" />
    
         <asp:Parameter Name="ContsMailAddr1" Type="String" />
    
         <asp:Parameter Name="ContsPhysAddr1" Type="String" />
    
         <asp:Parameter Name="ContsAltMailAddr" Type="String" />
    
         <asp:Parameter Name="ContsHomeMailAddr1" Type="String" />
    
         <asp:Parameter Name="original_ContsContactIDN" Type="Int32" />
    
         <asp:Parameter Name="original_ContsCompanyIDN" Type="Decimal" />
    
         <asp:Parameter Name="original_ContsContactFull" Type="String" />
    
         <asp:Parameter Name="original_ContsMailAddr1" Type="String" />
    
         <asp:Parameter Name="original_ContsPhysAddr1" Type="String" />
    
         <asp:Parameter Name="original_ContsAltMailAddr" Type="String" />
    
         <asp:Parameter Name="original_ContsHomeMailAddr1" Type="String" />
    
        </UpdateParameters>
    
      </asp:SqlDataSource>
    
    

    my Web.config connection string:

    	<connectionStrings>
     <add name="ConnectionString" connectionString="Data Source=TATTOOINE\SENATOR;Initial Catalog=&quot;C:\USERS\CHRISTOPHER\DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\WEBSITE1\APP_DATA\MYSTERIOUSCOPYDATABASE.MDF&quot;;User ID=christopherdterry;Password=seal!234"
      providerName="System.Data.SqlClient" />
     </connectionStrings>

    And I have the user set up to be enabled for eveything on the SGL side ..

    Monday, February 21, 2011 1:01 PM

Answers