473,837 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0 - GridView is not updating records.

44 New Member
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 />
  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>
Nov 20 '08 #1
2 1801
44 New Member
This problem has been resolved! Please close this question. Thanks =)
Nov 21 '08 #2
583 Contributor
Would you like to share the solution to the problem? If you want, for other users that search Google and find this thread...

Nov 21 '08 #3

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

Similar topics

by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass the applicable fields in the gridview to a sqldatasource which in turn calls a sproc with the appropriate parameters and data. Any ideas? Thanks in advance,
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
by: justin | last post by:
One of the gridviews i'm using now apparently needs to have the added functionality of re-arranging the order of the records it's representing. These records have a priority field which the dataset gets sorted on and I thought the quickest way to do this would be to add "move up", "move down" buttons next to the grid which would shuffle the rows up and down by swapping their priority field values and updating. At least that seemed to be...
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
by: Polaris | last post by:
Hi Experts: I'm using asp.net 2.0 with Visual Studio 2005. I'm trying to use the GridView to display data. I need to programmatically add rows into the GridView. So far could not find a way to do it. I appreciate it if any one can show a piece of code doing that.
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved, CrtdUser and Date And Edit and Delete buttons
by: brian | last post by:
I have a gridview that will contain 5000 + rows that is initially loaded into a dataset and bound to a gridview. On the form I have textboxes and dropdown list's I use to let the user fill in and click an add button to add new records. As I let users add records I update the SQL backend (insert a record). I want to programattically add a row to the gridview an not having to requery the table reload the dataset and bind each time a...
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know if that's what's causing the behavior or not. It seems like the Update button should at least do something. When the Edit button is clicked, the grid goes into Edit mode and the Cancel button takes the grid out of Edit mode. So, I don't get what...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.