ASP.NET 2.0 - GridView is not updating records.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xMetalDetectorx
    New Member
    • Oct 2008
    • 44

    ASP.NET 2.0 - GridView is not updating records.

    Hi Everyone,
    I have a very simple web app that uses .Net 2.0 login control to authenticate users and allow access to an "admin" folder. Inside that admin folder I have one page that has a SQLDataSource and a GridView control. I am using the GridView to test updating a very simple table in the database. The problem is, it will not Update the record at all! I placed this code outside of the admin folder and it worked fine. What could be causing this? My SQLDataSource and Gridview declarations are below:

    Code:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"             SelectCommand="SELECT * FROM [tblCategory]" InsertCommand="INSERT INTO tblCategory(title, description) VALUES (@title, @description)" UpdateCommand="UPDATE tblCategory SET title=@title, description=@description WHERE categoryID=@categoryID">             <UpdateParameters>                 <asp:Parameter Name="title" />                 <asp:Parameter Name="description" />                 <asp:Parameter Name="categoryID" />             </UpdateParameters>             <InsertParameters>                 <asp:Parameter Name="title" />                 <asp:Parameter Name="description" />             </InsertParameters>         </asp:SqlDataSource>         <br />         &nbsp;<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"             DataKeyNames="categoryID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="Both">             <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />             <RowStyle BackColor="#EFF3FB" />             <Columns>                 <asp:BoundField DataField="categoryID" HeaderText="categoryID" ReadOnly="true" SortExpression="categoryID" />                 <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />                 <asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />                 <asp:CommandField ShowEditButton="True" />             </Columns>             <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />             <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />             <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />             <EditRowStyle BackColor="#2461BF" />             <AlternatingRowStyle BackColor="White" />         </asp:GridView>
    Code:
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT * FROM [tblCategory]" InsertCommand="INSERT INTO tblCategory(title, description) VALUES (@title, @description)" UpdateCommand="UPDATE tblCategory SET title=@title, description=@description WHERE categoryID=@categoryID">
                <UpdateParameters>
                    <asp:Parameter Name="title" />
                    <asp:Parameter Name="description" />
                    <asp:Parameter Name="categoryID" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="title" />
                    <asp:Parameter Name="description" />
                </InsertParameters>
            </asp:SqlDataSource>
            <br />
            
    
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                DataKeyNames="categoryID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="Both">
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#EFF3FB" />
                <Columns>
                    <asp:BoundField DataField="categoryID" HeaderText="categoryID" ReadOnly="true" SortExpression="categoryID" />
                    <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
                    <asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />
                    <asp:CommandField ShowEditButton="True" />
                </Columns>
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
  • xMetalDetectorx
    New Member
    • Oct 2008
    • 44

    #2
    This problem has been resolved! Please close this question. Thanks =)

    Comment

    • joedeene
      Contributor
      • Jul 2008
      • 579

      #3
      Would you like to share the solution to the problem? If you want, for other users that search Google and find this thread...

      joedeene

      Comment

      Working...