.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Setting ASP Parameter value from a variable

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
I create a variable in code behind to save today's date.Dim date1 As New DateTime date1 = Now() And I want to save it as a parameter for an accessDataSource but I'm not finding anywhere that tells me how to do this properly. My attempts thus far have been<asp:Parameter DefaultValue="<% Response.Write(date1) %>" Name="date1" Type="DateTime" /> <asp:Parameter DefaultValue="date1" Name="date1" Type="DateTime" /> <asp:Parameter DefaultValue=date1 Name="date1" Type="DateTime" /> None of these are working! What is the proper way to do this?

View Complete Post

More Related Resource Links

Problem setting variable/param in XSLT for XML control in .NET 4.0

I am using an XML control in VS2010 with .NET 4.0.I am trying to sort XML data into a table. I have a drop list with the sort key, and a button that is supposed to display the table with a new sort.Here is the code the button calls:</p><p></p><p style="text-align: left;" mce_style="text-align: left;"><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><span class="Apple-style-span" style="border-collapse: collapse; line-height: 13px;" mce_style="border-collapse: collapse; line-height: 13px;" mce_fixed="1"></span></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">private void PopulateXML( Xml MyXML)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: h

Setting a session variable OR passing along information in Javascript

Hello, Form1 needs to send information to Form 2. Form2  opens in it's own window and is sized smaller. I need to send information to Form2 in order to set parameters in the query in Form2. At first I was just going to use an asp button control and load up some session variables, then I remembered that in order to have the next screen (Form2) open in its own window and be able to size it, I had to use an input type="Button" and use Javascript to open the new window like this:<script type="text/javascript"> function open_win() { window.open("/Accounts/Form2.aspx","_blank","toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=1000, height=500"); } </script> But by doing this, I don't know how to pass the information along I need for Form2. How can I pass variable information to Form2?  The data comes from two textboxes on Form1: txtStartDate and txtEndDate. Thank you. 

Passing a variable in @attachment parameter of sp_send_dbmail..




@sql varchar(100)



@TodayDate as varchar(40

Setting up a variable for a Bulk Insert Task in a For Each Loop


Is it possible to set up variables in a Foreach Loop for a Bulk Insert Task?

The Bulk Insert Task works fine without using a variable. But I have many file so I need to set the variable inside the Foreach Loop to read files one by one.

Everything I've tried keeps failing. I set my Destination and Source connections and then in the Bulk Insert Task Editor set up the expression with the variable that I have decalared (str_SourceFullName), and then set the bulk insert task delayValidation property to true and it keeps failing...I have tried almost changing every setting but it does not pick up the value of the variable.

I even tried to using an ActiveX Script Task by using the following script to pick up the variable, but the ActiveX Script errors out as well. Here is the ActiveX code:

Dim connmgr As ConnectionManager = Dts.Connections("Dialog2010.txt")

connmgr.ConnectionString = Dts.Variables("User::str_SourceFileName").Value.ToString()


 Has anyone had this problem?



How do you set SSIS package variable equal to an output parameter from a stored procedure that is ty


I have a stored procedure insertXXX that has one OUTPUT parameter of type numeric. The stored procedure looks like:



PROCEDURE [dbo].[insertIntoTable]
AS numeric OUTPUT




Access property of object as session variable as declarative datasource parameter value


I am storing a custom "Organisation" object as a session variable. One of the properties of  the Organisation object is "OrganisationID" (integer).

I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    SelectCommand="spGetUserJobList" SelectCommandType="StoredProcedure">
        <asp:SessionParameter Name="OrganisationID" SessionField="OrganisationID" Type="Int32" />

However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")?

 I have tried this, which does not seem to work:

<asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />


Setting a R/W Report Variable


SQL Server 2008 R2
Visual Studio 2008 + R2 BI tools

Is there an example of setting a Report variable in report code? In the example I'm building any reference to the Variables!<variablename>.SetValue gets an exception complaining about an object reference. How does one refer to these Report Variables in code?

Is there an ideal (best-practice) place where one can set a global variable visible to the Expressions created with the expression editor and the code in the imbedded code?

What's the difference between a ReportVariable and a Shared variable declared in the Code property (except for the fact that one is accessible in the Code and the other is not but can be seen in the Expression editor).


William Vaughn
Mentor, Consultant, Trainer, MVP

“Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)”

Please click the

Assign session variable value to update parameter


Hi, I'm trying to update a sqlserver database through vb.net in an asp.net 2.0 project. I'm using a sqldatasource and am trying to code an update parameter with a session variable.

code snippet:  

 <UpdateParameters><asp:Parameter Name="hrs_credited" />

<asp:Parameter Name="updater_id" DefaultValue="<%$ Session("User_ID")%>" Type

Where dose the application setting parameter saved?


I'm using a class derived from ApplicationSettingBase class to store my application's setting.

I know that the parameter mark as user parameter will save in "user.config" which under currentuser's folder , and I can modify it myself.

But I cann't find the file which the application parameter saved. I modify the .config file saved under my application folder, but the value not change.


Can someone tell me the path of that file or a method to modify application parameter? Thanks.

Setting a default value for a Unit type parameter


I want to include an optional parameter in a function statement that is of the type Unit. For example:

Public Shared Function NewTable(Optional ByVal TableWidth As Unit) As Table

Optional parameters require a default value, but I cannot figure out how to set a default value for a Unit type. Help! Thanks!

When creating a custom workflow activity, how can I specify a workflow variable as a parameter?


I have a functioning custom workflow activity developed in VisualStudio, deployed successfully and visible in SharePoint Designer.

My problem is that I'm trying to collect a Workflow Variable of type Number from SPD as a parameter for the activity, and can't find the right combination of values for my .ACTIONS XML file...

As a simple example/test WF Activity, I'm trying to just increment a variable and return the new value to another variable. Since this is an increment (variable++) I want both variables to be defined of type Number in SPD, not String. For an example of what I want, take a look at the "Do Calculation" OotB WFA in SPD and it's (Output To _variable:_ ) , where clicking on the parameter placeholder displays a drop-down list of all Workflow Variables in the current WF.

If I set the FieldBind attribute DesignerType to Text (and the Parameter attribute Type to "System.String, mscorlib") then I get the textbox with the "..." and "fx" buttons, allowing me to select any Workflow Data variables.

But if I change that to Integer and "System.Int32, mscorlib" I get the same control, but nothing is available in the Workflow Data variables list. And if I use FieldBind.DesignerType="ParameterNames" and Parameter.Type="System.int, mscorlib" I get an empty drop-down-

Local variable scoping in C#

In my previous post, Compiler-generated scopes for local variable declarations, I briefly touched on the issue of multiple meanings applied to the same name. In this post, I'll aim to flush out the compiler's rules with regards to binding names in their local scopes.

Compiler-generated scopes for local variable declarations

I was tasked with understanding and fixing a bug on error reporting with foreach iteration variables the other day, and it got me thinking about local variable scoping rules in C# in general. First, the bug.

Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


Setting the default start page in godaddy hosting?


 How do you set the start page with godaddy hosting? I can see no way of doing this! You do not seem to have access to the IIS settings that allow you to change it!

Retrieving a variable from a previous page



I'm looking to have a search page where a user will select an item from a listview, then then taken to another page that wil display data based on their original selection.

A user will type in a string and be presented with a list of usernames that are like that string, when they select a user name who's profile they would like to view I would like the page that they're taken to, to be that users profile.

How would I transfer the variable from the search page to the profile page, and when I work on the profile page, how can I access that variable?


Embeb a variable number of videos


I need to provide some alternate content for my non-Flash users.

I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form.

How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code.  But this seems inelegant.

Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend