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
- <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>
Expand|Select|Wrap|Line Numbers
- <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>