?
Solved

How to get the value of the variable in SqlDataSource  control?

Posted on 2009-02-15
3
Medium Priority
?
453 Views
Last Modified: 2012-05-06
Hi, please consider the following SqlDataSource control, I defined the output variable NewUser_ID, now where I can get its value in the code behind?
<asp:SqlDataSource ID="InsertAgent_SqlDataSource"  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            InsertCommand="INSERT INTO [User]([name], [Password], Full_Name,  Email,   IsDisabled, [Description], Date_Created, Date_PasswordModified, LoginCount, IsPasswordExpired, IsPasswordChangeable, MustChangePassword) 
                            VALUES (@username, @password, @firstname, @email, 0, @Description,GETDATE(), GETDATE(), 0, 0, 0, 0);SELECT @NewUser_ID = SCOPE_IDENTITY();
                            INSERT INTO [Path]([name], [Path_Location], [Description], Date_Created) 
                            VALUES (@name, @location, @PathDescription, GETDATE()); SELECT @NewPath_ID = SCOPE_IDENTITY();
                            INSERT INTO [Permission]([User_FK], [Path_FK], [Quota_Unlimited], [Traverse], [Create], [Delete], [Rename],[edit], [upload], [download], [compress], [cut], [copy], [paste],[listcontent],[extract]) 
                            VALUES (@NewUser_ID, @NewPath_ID, 1, 1,1,1,1,1,1,1,1,1,1,1,1, 1); " runat="server">
                <InsertParameters>
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtUsername" Type="String" Name="username"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtPassword" Name="password"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtFirstName" Name="firstname"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtEmail" Name="email"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtDescription" Name="Description"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtPathName" Type="String" Name="name"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtPathLocation" Name="location"  />
                    <asp:ControlParameter ControlID="frmvwAgentAdd$txtPathDescription" Name="PathDescription"  />
                    <asp:Parameter Direction="Output"  Name="NewUser_ID"  />
                    <asp:Parameter  Name="NewPath_ID"  />
                </InsertParameters>

Open in new window

0
Comment
Question by:Abdu_Allah
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 23646231
It's pretty simple, just intercept the "InsertAgent_SqlDataSource_Inserted" function.


  Protected Sub InsertAgent_SqlDataSource_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted
   Dim s as String = e.Command.Parameters("@NewUser_ID").Value
   'Do something with new ID
End Sub

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question