By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

ASP.NET 2.0 - GridView is not updating records.

P: 44
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:

Expand|Select|Wrap|Line Numbers
  1. <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>
Expand|Select|Wrap|Line Numbers
  1.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
  2.             SelectCommand="SELECT * FROM [tblCategory]" InsertCommand="INSERT INTO tblCategory(title, description) VALUES (@title, @description)" UpdateCommand="UPDATE tblCategory SET title=@title, description=@description WHERE categoryID=@categoryID">
  3.             <UpdateParameters>
  4.                 <asp:Parameter Name="title" />
  5.                 <asp:Parameter Name="description" />
  6.                 <asp:Parameter Name="categoryID" />
  7.             </UpdateParameters>
  8.             <InsertParameters>
  9.                 <asp:Parameter Name="title" />
  10.                 <asp:Parameter Name="description" />
  11.             </InsertParameters>
  12.         </asp:SqlDataSource>
  13.         <br />
  14.  
  15.  
  16. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
  17.             DataKeyNames="categoryID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="Both">
  18.             <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  19.             <RowStyle BackColor="#EFF3FB" />
  20.             <Columns>
  21.                 <asp:BoundField DataField="categoryID" HeaderText="categoryID" ReadOnly="true" SortExpression="categoryID" />
  22.                 <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
  23.                 <asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />
  24.                 <asp:CommandField ShowEditButton="True" />
  25.             </Columns>
  26.             <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  27.             <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  28.             <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  29.             <EditRowStyle BackColor="#2461BF" />
  30.             <AlternatingRowStyle BackColor="White" />
  31.         </asp:GridView>
  32.  
Nov 20 '08 #1
Share this Question
Share on Google+
2 Replies


P: 44
This problem has been resolved! Please close this question. Thanks =)
Nov 21 '08 #2

joedeene
100+
P: 583
Would you like to share the solution to the problem? If you want, for other users that search Google and find this thread...

joedeene
Nov 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.