473,626 Members | 3,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UpdateCommand of a DetailView

Is it possible to use a stored procedure instead of a SQL statement
with the update command on a detail view in asp.net 2005.

If so, how?? I can't seem to pass parameters into the stored
procedure.

Thanks in advance,
Jason

Aug 3 '06 #1
1 1526
1) we need a stored procedure
---------------------------------------
CREATE PROCEDURE usp_Products_Up date1
(
@UnitPrice money,
@UnitsInStock smallint,
@ProductID int
)
AS
UPDATE Products
SET UnitPrice = @UnitPrice,
UnitsInStock = @UnitsInStock
WHERE ProductID = @ProductID
GO

---------------------------------------

2)Build your details View with your SqlDataSource as the following
<asp:DetailsVie w ID="DetailsView 1" runat="server" AutoGenerateRow s="False"
DataKeyNames="P roductID"
DataSourceID="S qlDataSource3" Height="50px" Width="125px">
<Fields>
<asp:BoundFie ld DataField="Prod uctID" HeaderText="Pro ductID"
InsertVisible=" False"
ReadOnly="True" SortExpression= "ProductID" />
<asp:BoundFie ld DataField="Prod uctName"
HeaderText="Pro ductName" ReadOnly="True"
SortExpression= "ProductNam e" />
<asp:BoundFie ld DataField="Unit Price" HeaderText="Uni tPrice"
SortExpression= "UnitPrice" />
<asp:BoundFie ld DataField="Unit sInStock"
HeaderText="Uni tsInStock" SortExpression= "UnitsInSto ck" />
<asp:CommandFie ld ShowEditButton= "True" />
</Fields>
</asp:DetailsView >
<asp:SqlDataSou rce ID="SqlDataSour ce3" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>"
SelectCommand=" SELECT [ProductID], [ProductName], [UnitPrice],
[UnitsInStock] FROM [Products] WHERE ([ProductID] = @ProductID)"
UpdateCommand=" usp_Products_Up date1" UpdateCommandTy pe="StoredProce dure">
<UpdateParamete rs>
<asp:Paramete r Name="UnitPrice " Type="Decimal" />
<asp:Paramete r Name="UnitsInSt ock" Type="Int16" />
<asp:Paramete r Name="ProductID " Type="Int32" />
</UpdateParameter s>
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Grid View1" Name="ProductID "
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
You just specify your UpdateCommand as Stored procedure adn pickup your
Procedure.
Also note that Procedure Parameter matches field names with "@" at the
begining in your update procedure

Hope this will help you

Reagrds

--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
"jk***@charter. net" wrote:
Is it possible to use a stored procedure instead of a SQL statement
with the update command on a detail view in asp.net 2005.

If so, how?? I can't seem to pass parameters into the stored
procedure.

Thanks in advance,
Jason

Aug 3 '06 #2

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

Similar topics

0
1111
by: Mike | last post by:
I have a detailview, with several template columns in it. It's setup so that a user views info from a datagrid, and if they want to add another row, they click a button. The button causes a detailview to open up, in insert mode, they enter the data, hit insert, and the detailview goes away. Their data now appears in the gridview. When the user clicks the button to open the detailview, a few databound labels in 2 of the detailview's...
1
4257
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the param delcaration, then I have to invoke the update operation twice - by leaving the updated row - returning to the row and re-invoking the update procedure. Is there something else I need to do to add param values inline with the param...
6
13989
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
1
3068
by: Luqman | last post by:
The detailview control is combination of textboxes and labels, while detailview is in edit mode, how can I change the textbox value through code ? For example: My detailView has following fields. Code : Label1 Name : Textbox1
0
1240
by: Luqman | last post by:
I have used a single objectDataSource for GridView and DetailView, and when I load the page, the GridView shows all the entries of Invoice, and DetailView shows the 1st entry of Invoice, thats all ok. Now what I want is to click on Select Button of DetailView and that row should appear in DetailView, using the same ObjectDataSource, any idea ? I tried using : DetailView1.SelectedValue=GridView1.SelectedDataKey.Value
0
1159
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a GridView and Dataview controls. If user clicks on a row in GridView, the details will be shown in DetailView. 1/ I want to show in DetalView only details field - without column name, which is now shown on the left side next to details. How to hide the column name? 2/
2
3763
by: Luqman | last post by:
Hi, Any Idea how to Display Todays Date in DetailView Template Field while Inserting ? For example: When I click on New Button of DetailView Control, I need to display Today's Date in a Template Field text box. I tried following in DetailView1_ModeChanged Event but could not succeed. Protected Sub DetailsView1_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.ModeChanged
0
1517
by: LamSoft | last post by:
In the object of detailView, i added a function to check the values during itemUpdating, the source is: protected void test2(object sender, DetailsViewUpdateEventArgs e) { foreach (System.Collections.DictionaryEntry o in e.OldValues) { Response.Write("Old Values:" + o.Key.ToString() + "==>" + o.Value + "<br/>"); } foreach (System.Collections.DictionaryEntry o in e.NewValues) {
0
945
by: stuart_dent | last post by:
I have a SQL Server table with in Indetity column (value auto generated). I have tried to write my own updatecommand code. I can't get it to work. An error says that says Sku and rid are invalid column names. I don't know why. I even modified the Updatecommand the a bare bones
0
8262
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
8637
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
8364
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
8502
tracyyun
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...
1
6122
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
5571
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();...
0
4090
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...
1
2623
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
1
1807
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.