I have set up a GridView control bound to an SQLDataSource control.
Depending on which option a user selects in a DropDownList Each datasource is
a sethe select command retrieves a list of key/value pairs from a spefied
table. I am using a select query in the form of
SELECT PrimaryKey AS ID, Value AS Description from sometable
So that the gridview fields can always be bound to ID and Description fields
irespective of the table the data is comeing from. This works fine.
I am using TemplateFields in the gridview for the data. In the
ItemTemplates the description fields is bound to a Label control and the ID
field is bound to a hidden copntrol. In the EditItemTemplat e i am using a
TestBox control for the description and a hidden control for the ID. I am
also using a similar method with a DetailsView control for inserting items.
I am using the <%# Bind("Descripti on") %> syntax to bind the data to the
controls in the TempalteFields. Viewing, Inserting and Updating all work
fine.
However when i try to delete a record i get the following error:
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.Sql Client.SqlExcep tion: Must declare the
variable '@ID'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
The delete query i am using is as follows:
DELETE FROM TableName WHERE (PrimaryKey = @ID)
and i have DeleteParamters section as follows:
<DeleteParamete rs>
<asp:Paramete r Name="ID" />
</DeleteParameter s>
If i remove the hidden field which is bound to the ID field, from the
ItemTemplate section i don't get the error, but obviously it doesn't delete
the record either. When i run the delete query in visual studio directly it
simply asks me for the value of paramtere @ID and then delete the correct
record.
I am sure i am missing something simple but fundamental but i can't figure
out what is wrong. 2 1282
Do you have the property datakeynames filled in?
"clickon" <cl*****@discus sions.microsoft .com> wrote in message
news:B5******** *************** ***********@mic rosoft.com... I have set up a GridView control bound to an SQLDataSource control. Depending on which option a user selects in a DropDownList Each datasource is a sethe select command retrieves a list of key/value pairs from a spefied table. I am using a select query in the form of
SELECT PrimaryKey AS ID, Value AS Description from sometable
So that the gridview fields can always be bound to ID and Description fields irespective of the table the data is comeing from. This works fine.
I am using TemplateFields in the gridview for the data. In the ItemTemplates the description fields is bound to a Label control and the ID field is bound to a hidden copntrol. In the EditItemTemplat e i am using a TestBox control for the description and a hidden control for the ID. I am also using a similar method with a DetailsView control for inserting items. I am using the <%# Bind("Descripti on") %> syntax to bind the data to the controls in the TempalteFields. Viewing, Inserting and Updating all work fine.
However when i try to delete a record i get the following error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.Sql Client.SqlExcep tion: Must declare the variable '@ID'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
The delete query i am using is as follows: DELETE FROM TableName WHERE (PrimaryKey = @ID)
and i have DeleteParamters section as follows:
<DeleteParamete rs> <asp:Paramete r Name="ID" /> </DeleteParameter s>
If i remove the hidden field which is bound to the ID field, from the ItemTemplate section i don't get the error, but obviously it doesn't delete the record either. When i run the delete query in visual studio directly it simply asks me for the value of paramtere @ID and then delete the correct record.
I am sure i am missing something simple but fundamental but i can't figure out what is wrong.
No I didn't, and that fixed it thanks.
As you may be able to tell, i am still learning.
"Maarten" wrote: Do you have the property datakeynames filled in?
"clickon" <cl*****@discus sions.microsoft .com> wrote in message news:B5******** *************** ***********@mic rosoft.com...I have set up a GridView control bound to an SQLDataSource control. Depending on which option a user selects in a DropDownList Each datasource is a sethe select command retrieves a list of key/value pairs from a spefied table. I am using a select query in the form of
SELECT PrimaryKey AS ID, Value AS Description from sometable
So that the gridview fields can always be bound to ID and Description fields irespective of the table the data is comeing from. This works fine.
I am using TemplateFields in the gridview for the data. In the ItemTemplates the description fields is bound to a Label control and the ID field is bound to a hidden copntrol. In the EditItemTemplat e i am using a TestBox control for the description and a hidden control for the ID. I am also using a similar method with a DetailsView control for inserting items. I am using the <%# Bind("Descripti on") %> syntax to bind the data to the controls in the TempalteFields. Viewing, Inserting and Updating all work fine.
However when i try to delete a record i get the following error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.Sql Client.SqlExcep tion: Must declare the variable '@ID'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
The delete query i am using is as follows: DELETE FROM TableName WHERE (PrimaryKey = @ID)
and i have DeleteParamters section as follows:
<DeleteParamete rs> <asp:Paramete r Name="ID" /> </DeleteParameter s>
If i remove the hidden field which is bound to the ID field, from the ItemTemplate section i don't get the error, but obviously it doesn't delete the record either. When i run the delete query in visual studio directly it simply asks me for the value of paramtere @ID and then delete the correct record.
I am sure i am missing something simple but fundamental but i can't figure out what is wrong. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: A |
last post by:
Hi,
I'm trying to solve the 3rd and final case in deleting a node from a binary
tree. That is, deleting a node that has two subtrees. If someone out there
who knows about this problem as they have done it before or is currently
doing something similar then please give me some links with code.
Regards,
dfgf
|
by: Rick |
last post by:
Hi,
Does deleting an object more than one times incur undefined behavior? I
think it doesn't but just making sure... thanks
Rick
|
by: Matan Nassau |
last post by:
Hello.
i have a composite which i want to delete. this is a composite which
represents a boolean expression (see a previous post of mine with more
details at http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&threadm=AXqqc.89218%24PJ1.865449%40wagner.videotron.net&rnum=1&prev=/groups%3Fq%3Dmatan%2Bnassau%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DG%26scoring%3Dd
)
VariableExp *x = new VariableExp("X");
VariableExp *y = new VariableExp("Y");...
|
by: Fughal |
last post by:
Hi,
I have a big DB2 database and I need this database without any Data in
it for testing something. I have made a backup of these db and restore
it on a testing system. My Problem is now how can I delete all Data
because there are more than 500 tables in the db, it’s impossible to
delete all by hand.
I thought theres is another way to do this: only copy the structure of
the database into another DB, here is my problem how can I copy...
|
by: Bob Darlington |
last post by:
I have a repair and backup database routine which runs when a user closes
down my application.
It works fine in my development machine, but breaks on a client's at the
following line:
If Dir(strLDB) <> "" Then Kill (strLDB)
where strLDB is the path to the ldb file.
The client advises that the ldb doesn't lurk after the program closes.
Any ideas?
| |
by: Martin Bischoff |
last post by:
Hi,
I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123)
to allow users to upload files. When I later delete these directories (from
the code behind), the application restarts and all active sessions are
terminated.
This error is also described in detail here:...
|
by: George |
last post by:
VB.net 2003 standard, XP windows home edition.
Installed first application OK today.
When I removed the application via Control Panel, there were no
problems and the app folders were deleted.
But when I installed the app from a CD-ROM (Release folder is in D:),
when I remove the app in Control Panel these problems occur:
Control Panel does not delete the application folders.
When I try to delete them I get message "Cannot delete file:...
|
by: Joe Van Dyk |
last post by:
When you delete a pointer, you should set it to NULL, right?
Joe
|
by: Kimera.Kimera |
last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all
files, folders, sub-folders and sub-sub folders (etc).
The program is simply for deleting the Windows/Temp folder contents,
removing all the files/folders inside it.
The problem i am having is that i can only delete files in the
Windows/Temp folder, and i can't delete folders if they contain files,
i know that you can't do this.
|
by: Kyosuke18 |
last post by:
Hi everyone,
I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in query expression 'ID=". Here is the code that i did:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim ab As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My...
|
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: 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,...
|
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: 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,...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |