473,732 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update error in GridView

58 New Member
Hi,

This should be ridiculously simple, but I just can't get the update to work in GridView for ASP.NET. Here's the very simplified code:

Expand|Select|Wrap|Line Numbers
  1.             <asp:SqlDataSource id="ProductsSource" Runat="Server"
  2.                 ConnectionString="<%$ ConnectionStrings:ConnectionStringTraining %>"
  3.                 ProviderName="<%$ ConnectionStrings:ConnectionStringTraining.ProviderName %>"
  4.                 SelectCommand="SELECT training_unit_id, training_unit_name FROM training_units"
  5.                 UpdateCommand="UPDATE training_units SET training_unit_name=@training_unit_name
  6.                      WHERE training_unit_id=@training_unit_id"
  7.             />
  8.  
  9.             <asp:GridView id="EditGrid" DataSourceID="ProductsSource" Runat="Server"
  10.                   AutoGenerateEditButton="True"
  11.                   DataKeyNames="training_unit_id"/>
  12.  
The select runs fine, but when I try to do the update (hit "Edit", make a change, then hit "Update"), I get the message: Must declare variable '@training_unit _name'. I've tried uisng the UpdateParameter s tag, but to no avail.

This is pretty simple. Why isn't it working?

Robert
Apr 14 '08 #1
0 840

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

Similar topics

1
2490
by: Scott F K Hooper | last post by:
VB.NET 2.0 project... I have an Access database with a table that has one primary key. I have used the Add TableAdapter wizard in VS2005 to create my TableAdapter. Next I added an ObjectDataSource object to a new aspx form, chosen the newly created TableAdapter and selected the parameterised Update command from the drop list provided. Finally I added a GridView control and bound it to the ODS. The problem I have is an error I get when...
1
2774
by: Scott F K Hooper | last post by:
My ASP.NET 2.0 project has a GridView that I want to be able to edit and update records with. The GridView has been bound to an ObjectDataSource control that has the following Update method signature: Update(Nullable<Int32> Tile_Number, String Tile_Name, String Tile_Path, Nullable<Decimal> Value, Boolean Sold, Boolean Payment_Verified, Nullable<Byte> Owner_Type, String Line_1, String Line_2, String First_Name, String Last_Name, String...
3
2770
by: tarscher | last post by:
Hi all, I have a grid that contains 7 columns from 3 tables (3 unique keys, 4 normal fields). I show this 7 columns on the gridview. I now want to add edit and delete functionality. This should be fairly easy cos it's a build in feature of the gridview but alas... When the user clicks delete only one row on one table needs to be deleted thus I made a new query in my Datatable (DeleteissueQuery) that excpects an id
0
4347
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables need to be updated based on the data in the gridview. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:slightsInventoryConnectionString %>" SelectCommand="SELECT * FROM " UpdateCommand="upd_Inventory"...
4
6081
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters are being populated. Integers are being passed as 0 and strings are empty regardless of what I changed them to in Edit mode on the GridView. My object method to perform the update:
2
3000
by: Looch | last post by:
Hi, I'm filling a GridView with a simple sproc select statement. I'm trying to use the Update tab to create an update statement and using the following: Update Shipping_Requests Set Shipped = @Shipped The Shipped column is a bit type column that is returned in the
0
2960
by: Jeff | last post by:
hey asp.net 3.5 I have 2 UpdatePanels in my webpage. This webpage has a GridView, which one of its column is a templatefield which again contain a UpdatePanel and a button... The other UpdatePanel is located outside the GridView....
2
2483
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a contact in our database. I also need to use the Edit and Delete funtions in the gridview. Neither seems to be working as intended.
5
2175
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is always 0 and not the ID of the selected record (which is the case when updating) How come?
4
3924
by: ahling | last post by:
Hi all. As mentioned in my first post, I'm currently doing an asp.net blog where user can update their profile, and update their blog entry. But I encountered problem with the update of entry part. When I tried to post a blog entry by hitting the 'Post' button, it brings me to a blank page which is supposed to show me the gridview that contains the Blog subject, title of the blog entry, date and the name of the poster itself. But what...
0
8944
marktang
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...
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9306
jinu1996
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...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
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...
1
6733
isladogs
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...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.