473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SqlDataSource DeleteParameters

I'm a little confused as to how the SqlDataSource works with its
DeleteParameters. I have a GridView hooked up to my SqlDataSource.
Here is my templatefield with my Delete button :

<asp:TemplateField HeaderText="Select">

<ItemTemplate>

<asp:LinkButton ID="DeleteButton"

CommandArgument='<%# Eval("ForecastKey") %>'

CommandName="Delete" runat="server">

Delete</asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

And here is my SqlDataSource :

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:XeroxConnectionString %>"

SelectCommand="ViewForecast" SelectCommandType="StoredProcedure"

DeleteCommand="DeleteForecast" DeleteCommandType="StoredProcedure">

</asp:SqlDataSource>

My stored procedure requires 1 parameter (ForecastKey) to be passed to
it, but I can get away with not specifying DeleteParameters in my
SqlDataSource and it still deletes the record. Any ideas why it does
this, and whether this method of not specifying parameters is a
recommended way to do this?


*** Sent via Developersdex http://www.developersdex.com ***
Jun 1 '06 #1
1 5625
The values defined in DataKeyNames of your DataBoundControl are always passed
as arguments to the various commands (update, insert, delete), so no declarative
parameter is required (*despite* the silly designer/wizard putting one in).
Same goes for all columns that are returns from the SelectCommand -- IOW,
those are always passed to your various update commands as well.

-Brock
http://staff.develop.com/ballen

I'm a little confused as to how the SqlDataSource works with its
DeleteParameters. I have a GridView hooked up to my SqlDataSource.
Here is my templatefield with my Delete button :

<asp:TemplateField HeaderText="Select">

<ItemTemplate>

<asp:LinkButton ID="DeleteButton"

CommandArgument='<%# Eval("ForecastKey") %>'

CommandName="Delete" runat="server">

Delete</asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

And here is my SqlDataSource :

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:XeroxConnectionString %>"

SelectCommand="ViewForecast" SelectCommandType="StoredProcedure"

DeleteCommand="DeleteForecast" DeleteCommandType="StoredProcedure">

</asp:SqlDataSource>

My stored procedure requires 1 parameter (ForecastKey) to be passed to
it, but I can get away with not specifying DeleteParameters in my
SqlDataSource and it still deletes the record. Any ideas why it does
this, and whether this method of not specifying parameters is a
recommended way to do this?

*** Sent via Developersdex http://www.developersdex.com ***

Jun 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: fuchs.markus | last post by:
Hello, on my page, I have a DetailsViewControl connected to a SqlDataSource. Now when I dynamically set the FilterExpression and FilterParameters - for example in a OnClick-EventHandler of a...
8
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...
3
by: Wayne Wengert | last post by:
Using VSNET2005. I want to insert some rows into a table. Each row has 2 columns, "memberid" which is a GUID and "Interests" which is a varchar. I created a SQLDataSource with the values to insert...
3
by: Jim Andersen | last post by:
Just to let you know, and to help any future sorry sods who gets trapped in the same black hole...... You can't just copy/move a working sql-statement into a stored procedure. Working with a...
0
by: Ed | last post by:
All of a sudden my previously working code started throwing this error. from the SqlDatasource. I am using C# and Asp.net 2.0. Getting the following error: You have specified that your delete...
1
by: nate | last post by:
I am getting this error. System.Data.SqlClient.SqlException: Must declare the variable '@InventoryID'. At first I left the parameter declaration in the aspx page and then I tried moving it to...
2
by: djc | last post by:
1) I am wondering if I should be using an sqlDataSource object for my particular scenario. I need to loop through a listbox and perform an INSERT sql operation for each item. Could be a few or...
1
by: David Lozzi | last post by:
Howdy, ASP.Net 2.0 using VB on SQL 2005 This is a two fold issue. I have a DetailsView control which users can insert or edit items. Editing works great. Insert works great however I need...
1
by: David C | last post by:
I have aspx web page with a GridView that displays data from a SqlDataSource view that combines 2 tables to show information. It has an Edit feature and the SqlDataSource has an UpdateCommand text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.