DataSource Controls :: Setting Parameter Value From A Variable?
Sep 3, 2010
I create a variable in code behind to save today's date.
[Code]....
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
[Code]....
View 4 Replies
Similar Messages:
May 20, 2010
I have several web forms which use a GridView linked to a DataSource control which is defined at design time as follows:
<cc1:pgsqldatasource
id="dsStates"
runat="server"
connectionstring="<%$ ConnectionStrings:PgSqlConnection %>"
oldvaluesparameterformatstring="Original_{0}"
providername="<%$ ConnectionStrings:PgSqlConnection.ProviderName %>" >
</cc1:pgsqldatasource>
As you can see, the connectionstring parameter is defined to a specific connection string name and I need to be able to set such a parameter to a different value, for example, to a session variable content.
View 1 Replies
Oct 27, 2010
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:
[Code]....
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" />
View 2 Replies
Mar 25, 2010
I've done some SSIS package work in the past, but am by no means an expert.
I want to use an SSIS package to do the following:
1. Get the file name of the newest file in a windows folder (using a filename template like his: filename_ *.txt where the * part is always a date in the format of yyyy-mm-dd.
2. Use that file name in later portions of the SSIS package by reading the file and transferring data from it to a SQL table using a Data Flow task.
and use the result (which should be the name of the newest file) to open that file and pull data out of it and into a 2nd SQL table. I admit, I'm not sure how to use the dynamic result of this SELECT query as the file name in a flat file connection manager.
View 6 Replies
Jan 7, 2010
I need to use a global variable as a parameter for the SqlDataSource element. I capture the user Name when he/she logs in:
Public UserName As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
UserName = Page.User.Identity.Name
End Sub
Then, I need to use the UserName to search the SQL DB and show only logged user personal information.
SelectCommand="SELECT * FROM [Member] where [UserID]= UserName"
What is the sintaxe to use a global variable into the SQL Select Command?
View 10 Replies
May 19, 2010
how can i set the parameter source of an SqlDataSource to a variable from visual studio?
View 2 Replies
Mar 11, 2010
How do you use the http POST method with a Grid View on another page. I am trying to use the POST method to send the ID from the selected row of a Grid View, I am using a link button set to fire the select command and it has the Post Back URL set, from one page and then retrieve the ID value on another page using an Object Data Source. Also, under the Defining Parameters, I am setting the ID parameter to Form Parameter Source and have entered the Grid Views name in the Form Field.
View 4 Replies
Sep 13, 2010
Right now I have a RadToolTip inside of a RadGrid. The RadGrid displays a field from the datasource called "Value". The RadToolTip displays the same thing.
I want to add another RadGrid inside of the RadToolTip. The function setting up the datasource of that second RadGrid should take "Value" as a parameter?
How do I do that?
Here's what I have so far.
[code]....
View 1 Replies
Jan 26, 2010
This may be elementary user control stuff, but I can't get it to work.
How can I pass the Membership.GetUser.UserName variable (or any variable) through a user control parameter at load time?
[Code]....
The only thing that I was able to do was to create the User Control object in the code behind and then add it to the page. Although that works, it doesn't seem like the correct way to program.
View 1 Replies
Mar 21, 2010
I have a formview bound to a sqldatasource control. I want to set one of the insert parameters when I click on one of several buttons (outside the formview).
In my sqlDS I have:
<InsertParameters>
<asp:Parameter
Name="benType"
Type="byte"
/>
<asp:Parameter
Name="benName"
Type="String"
/>
<asp:Parameter
Name="benDesc"
Type="String"
/>
</InsertParameters>
I want to set the "benType" depending on which button I've pressed (I don't want/need it to be visible in the InsertTemplate). I tried adding this line to the codebehind for the button click:
formview1.ChangeMode(FormViewMode.Insert)
formview1_datasource.InsertParameters(0).DefaultValue = 2
This doesn't work...what is the best way to set the insertParameter from outside the formview?
View 6 Replies
Jan 19, 2011
I have a Stored Proc which uses a field in the database. that ends up being the user.identity.name. So, when the page loads, it grabs that name and uses it in the stored proc, which I'm which I'm wanting to designate in the sql datasource. But it only gives me choices of querystring, cookie, session, control, etc. My question is how to reference that variable as the parameter in the datasource?
View 3 Replies
Jun 26, 2010
I am working with a repeater control for a reporting purpose.
I have 2 repeaters one inside another , i hvae to bind the second repeater with the help of function which is having two parameters to pass in it
<asp:Repeater
ID="Rptgsaaccount"
runat ="server"
DataSource ='<%#bindcourse(Eval("Session_Id"),2nd parameter)%>'>
the first parameter is i am easily getting from outer repeater, but the second parameter value is exist on the server side and in a session variable
i have to pass this server side session variable value in above mentioned function as a second parameter .
View 2 Replies
Mar 25, 2010
I need to pass the control parameter to Sql Datasource in code behind,
<asp:ControlParameter ControlID="DDL_RType" Name="rtype" PropertyName="SelectedValue"
View 3 Replies
Mar 11, 2011
I would like to run a SQL query on the codebehind VB page that will also set a value from that query to a Session variable. Also, this needs to be done on the Page_Load.
Example:
[Code]....
View 3 Replies
Jun 14, 2010
In the following code, you'll see that the method 'getImage' is called and passes in a filepath. I want this filepath to be dependant upon a selection on a previous page- so instead of it constantly being 'properties/cedar', it could be 'properties/eastlodge' for example.
[Code]....
View 3 Replies
Mar 3, 2010
I am trying to modify a .ascx file, to declare a variable. I've read that this is normally done in the code behind view, but I do not have access to the code behind, and this is a very small addition. We are using DotNetNuke, and in the .ascx file I have written
<script runat="server">
String foo = "bar";
</script>
And this causes the page to explode. I have some experience with PHP, but am very new to .NET. Is there a way to define a variable in a .ascx file in this way? Maybe I have not imported all the correct libraries at the top of the page?
View 7 Replies
Mar 1, 2010
first off I can't post the code, so I will do my best to try to explain what I am trying to do. I have a repeater with three literals (a member ID, a name, a uservalue) and three hyperlinks. Each of the hyperlinks goes to a different page (obviously).What I am trying to do is when the user clicks on one of the hyperlinks, (doesn't matter which one because the three literals need to be put into session variables regardless) I want the session variables set to the literal values before calling the next page.How do I get the session variables set when the user clicks on one of the hyperlinks?
View 9 Replies
Apr 13, 2010
I'm building a site (it's amazing how much you can do and still not know what you're doing).I have my visitor login from a login.aspx page and, when authenticated are redirected to a Portal page. On that Portal page at pageload I set a Session variable "UserName" using the User.Identity.Name like this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.Identity.Name <> "" And User.Identity.IsAuthenticated = True Then
If Page.IsPostBack = False Then
Session("UserName") = User.Identity.Name
End If
[code]...
View 4 Replies
Mar 17, 2010
I'm having a hard time understanding why the following code doesn't work. I'm sure it's something remedial that I'm missing or not understanding. I currently have a page that asks for user input. If, based on the input and logged in user, I find data from this page already in the database, I need to update the existing records rather than creating new ones, so I set a class-level bool to true. The problem is, when MyNextButton is clicked, PreviouslySubmitted is still false. So, I'm not sure how to make the value of this variable persist.
public partial class MyForm : System.Web.UI.Page
{
private bool PreviouslySubmitted;
protected void Page_Load(object sender, EventArgs e)
{
MyButton.Click +=
(o, i) =>
{
q = from a in db.TableA
where (a.SomeField == SomeValue)
select a;
if(q.Any())
{
PreviouslySubmitted = true;
//populate the form's fields with values from database for user to revise
}
}
MyNextButton.Click +=
(o, i) =>
{
//the value of PreviouslySubmitted is false at this point,
//even if I made sure it was set to true the previous postback
if(PreviouslySubmitted)
{
//update database
}
else
{
//insert into database
}
}
View 2 Replies
Mar 17, 2010
I have a ListView that, among other things, in the EditItemTemplate, has a pair of related DropDownList controls, sort of a parent/child relationship. The selected value of the parent is used as a parameter for the SQL Datasource of the child. Outside of a control such as the ListView, this would be easy and I'd simply set up a ControlParameter for the SQL Datasource and life would be good. Within the DataList things are not quite so simple. My plan is to set the parameter of the child in the Selecting handler of its datasource. I have hard coded some values and this works the way I want it to. My problem is getting the "parent" value. I've got two theories on how to get this:
#1, I've tried instantiating the parent DropDownList but it is either not available at this point in the page life cycle or I just don't know the syntax to get at it from within the Selecting handler.
#2, I'm thinking I may have to grab the value from the underlying data for the ListViewRow that I am editing, but again, I do not know the object model well enough to get at those values.
Below is a code sample for option #1. As stated, setting the parameter works, but getting the value of the DropDownList does not.
View 5 Replies
Mar 26, 2010
I'm getting a very peculiar problem with my asp.net application, it took me an age to track down but I still don't know what is causing this behaviour.
If I set a session variable in the Application_PreRequestHandlerExecute event, then my external JavaScript files are ignored, and therfore causing a raft of errors. I have simplified the problem below.
E.g.
I have file called JScript.js containing the code:
function myAlert() {
alert("Hi World");
}
And in my Default.aspx file I reference the js with the code:
<script src="JScript.js" type="text/javascript"></script>
And in the body onload event I call the myAlert() function:
<body onload="myAlert()">
And finally in the Global.asax file:
Private Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
HttpContext.Current.Session("myVar") = "MyValue"
End Sub
If you run the Default.aspx file you will see the js function isnt called, however, if you comment out the line of code Global.asax then the external js is called and the function executed when the page loads.
View 1 Replies
Aug 3, 2010
What am i missing or doing wrong here, when i debug, im seeing the selected value in the code behind, but when the page loads, it says the following:
Procedure or function 'Onsite_Report_Procedures' expects parameter '@rptNum', which was not supplied.
<asp:SqlDataSource
ID="SQLOnSiteReport"
runat="server"
ConnectionString="<%$ ConnectionStrings:connectn %>"
SelectCommand="Onsite_Report_Procedures"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="@rptNum" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
[Code]....
View 2 Replies
Aug 4, 2010
I have a stored procedure with output parameter. I encapsulate it with Table Adapter and BLL. Call it using ObjectDataSource in conjuction with formview, just like the one in Data Access Tutorial. How do I get the output parameter in event INSERTED of the ObjectDataSource in code behind (VB)?
My stored procedure looks like this:
[Code]....
My BLL code looks like this:
[Code]....
View 2 Replies
Jul 12, 2010
We have a stored procedure which creates and returns as output the next value in line:
[Code]....
Yes, the dullards who created this system not only failed to use an identity for the primary key of this table, they then proceeded to add 1 to a varchar column to create the new value, thus insuring it can never be anything but numeric.
Sigh. I'm told we cannot address that obvious deficiency now, and we have to leave the column as varchar. Double sigh.
If I execute this sproc from SSMS, the hh_num variable is returned as expected:
[Code]....
However, when I run it through the application, the parameter I set up as output does not get its Value attribute changed:
[Code]....
I've verified that the "@hh_num" maintains its direction and name through the ExecuteNonQuery call, but its Value remains an empty string.
View 1 Replies
Jun 5, 2010
I want to use parameter in SQL command, Which the following code is better and why?
string id= getId();
SqlCommand cmd1 = cn1.CreateCommand();
cmd1.CommandText = " INSERT INTO std(idStd) VALUES (idStd=id) ";
cmd1.ExecuteNonQuery();
string idF = getId();
SqlCommand cmd1 = cn1.CreateCommand();
cmd1.CommandText = " INSERT INTO std(idStd) VALUES (idStd=@id) ";
cmd1.Parameters.AddWithValue(@id, idF);
cmd1.ExecuteNonQuery();
View 3 Replies