Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2009, 01:22 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can i pass a dynamic (vdUser) value to either UpdateCommand or UpdateParameters

in webform.aspx has

<body>
<% String vdUser = Request.ServerVariables["AUTH_USER"]; %>
...

<asp:SqlDataSource ID="dg_vendorTrk" runat="server"
ConnectionString="<%$ ConnectionStrings:conn_vendor_server %>"
...
UpdateCommand="UPDATE table1 SET vdLogAs=@vdUser WHERE (vdId=@vdId)" >
<UpdateParameters>
<asp:QueryStringParameter Name="vdUser" DefaultValue="<%= Request.ServerVariables["AUTH_USER"] %>" />
</UpdateParameters>
</asp:SqlDataSource>
...

<asp:GridView
ID="GridView2" runat="server" AllowPaging="True"
…
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="vdId" HeaderText="vdId" InsertVisible="False" ReadOnly="True" SortExpression="vdId" />
<asp:BoundField DataField="vdLogAs" HeaderText="LogAs" ReadOnly="true" SortExpression="vdLogAs" />
…
</asp: GridView>





Please HELP, how can i pass a vdUser to either UpdateCommand or UpdateParameters
 
Old September 30th, 2009, 04:48 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You need to handle the SDS's Updating event and then assign the value to the relevant UpdateParameter:
Code:
 
 
Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) _
           Handles SqlDataSource1.Updating
  SqlDataSource1.UpdateParameters("User").DefaultValue = Context.User.Identity.Name
End Sub
http://msdn.microsoft.com/en-us/libr....updating.aspx
http://msdn.microsoft.com/en-us/libr...arameters.aspx

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Stored Procedure as UpdateCommand nickoy ASP.NET 3.5 Professionals 8 April 1st, 2009 02:05 PM
How to pass the dynamic XML file name to XSL jle XSLT 3 March 13th, 2008 04:20 PM
GridView UpdateCommand Sheraz Khan ASP.NET 2.0 Professional 2 August 28th, 2007 07:24 AM
UpdateCommand ozzy VB.NET 2002/2003 Basics 4 January 24th, 2005 05:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.