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


Post New Web Links

How to pass variable to objectDataSource???

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
 
Could someone please help me with this?I have an objectDataSource which uses my stored procedure GetNotificationsAnd my GridView is bound to that objectDataSourcethe only problem is that my stored procedure requires the variable @UserName and then returns the values for that username, but I do not know how to pass the variable to the objectDataSource, does anyone know the code for this?I can get userName from HttpContext.Current.User.Identity.Name but how do I pass that to the objectDataSource?


View Complete Post


More Related Resource Links

How to retrieve data from SqlDataSource and pass to a variable?

  

Hi there,

I have a page in my website where there is very little code-behind. I only have two lines of code in Page_Load() and the rest of the code is declarative ASP.NET code. I have a FormView control which uses a SqlDataSource to get some order information. The SqlDataSource calls a stored procedure called usp_GetOrderDetails, here's the code for the SqlDataSource:

    <asp:SqlDataSource ID="sdsFormOrderDetails" runat="server" 
ConnectionString="<%$ ConnectionStrings:ForexDB %>"
ProviderName="<%$ ConnectionStrings:ForexDB.ProviderName %>"
SelectCommand="usp_GetOrderDetails" SelectCommandType="StoredProcedure"
UpdateCommand="usp_UpdateOrder" UpdateCommandType="StoredProcedure"
>
<SelectParameters>
<asp:ControlParameter Name="orderId" ControlID="grdOrders" PropertyName="SelectedDataKey.Value" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter Name="orderId" ControlID="frmOrderDetails" PropertyName="SelectedValue" />
</UpdateParameters>
</asp:SqlDataSource>

Pass the server variable to search core result web part

  

I'd like to custom the search core result web part to filter results based on the log on user name.

It can easily be done in Dataview web part.

However the search core web part doesn't accept "<parameterbining>" to pass in the server variable [logon_user]. I can't figure out how to use <xsl:param> to get this server variable either.

 

Any ideas? Thanks a lot!


If you get confused, listen to the music play...

Can I pass a value for a output variable in a stored procedure in ADO.NET?

  
I am calling a stored procedure, that exists in a SQL Server 2005 database,  using ADO.NET, in which I instantiate a sql command object.The stored procedure has an ouput variable like '@packageCode VARCHAR(100) = NULL OUTPUT'.Can I set it's value when creating the sql command object? Or I can never set a value for an output type variable in  a stored procedure?

Customize form to add new item - can i pass through a variable?

  

I have a list of issues stored in a SharePoint list.

I now want to store tasks relating to these individual issues.
Ideally, when a user is viewing the issue they can then click on an 'add task' link that will open up a new task, in a standard task list, and pass through the issue id into a custom field.

Any ideas?


I need to pass a variable from a url to an .aspx search/results page

  

When I was using FrontPage, a .asp page would receive a varialbe from the url when ?field=value was added to the end of the url.  I am now using Expression Web and have found that this doesn't work with .aspx pages.  Can anyone tell me what code needs to be added to the page to accomplish this with .aspx?  I create the .aspx page with VB as the coding selection.

I am not sure what forum this should be in.

 

thanks,

Eleanor V


How to pass a variable from parent to the hosted page in a frame. (Cross Posted due no reply from (V

  

Hi,

I have - what might look like an obvious question - for me it is a headache.

Some background info:

In a WPF Window, I have placed a frame. A Ribbon button in the WPF window executes NavigationServices as you can see below. Mind there is no navigation History (back/Forward).

    Private Sub rTabToolsRgpSystemAdministrationRbtnPolicyEditor_Click(ByVal sender As ObjectByVal e As System.Windows.RoutedEventArgsHandles rTabToolsRgpSystemAdministrationRbtnPolicyEditor.Click
        InsertNavigationAction("Policy Editor")
        piFrame.NavigationService.Navigate(New System.Uri("piPolicyEditor.xaml"UriKind.Relative))

I am trying to pass a string variable (s

Pass Id To ObjectDataSource From DetailsView Control

  

Hello all

I have an objectDataSource to retrieve data and fill a listBox on edit

I created a BLL method to get the data and set the controlId to the detailsVeiw control but the id is not passed throuh to the bll class

this is my code:

    <asp:ObjectDataSource ID="odsItems" runat="server" 
        SelectMethod="GetRecords" TypeName="BLL.GetData.Get">
        <SelectParameters>
            <asp:ControlParameter ControlID="detailsVeiw" Name="id" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:DetailsView ID="detailsVeiw" runat="server" AutoGenerateRows="False" DataSourceID="odsByKey" DataKeyNames="id">
<Fields>
            <asp:TemplateField HeaderText="Code" SortExpression="id">
                <EditItemTemplate>
                    <asp:Label ID="lblIdEdit" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblIdItem" runat="server" Text='<%

how to pass variable into SQL query in aspx

  

sales.aspx.vb

custom function which stores the current DATE into todayDate. I use this function  to convert system date into SQL friendly date. 

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

sales.aspx

I used Data Grid and SQL Data source. 

SelectCommand="select * from sales where aab = 110026"

======================================================================

I want my select statement should take the date from todayDate.

ie: SelectCommand="select * from sales where aab = todayDate"


Help me to write this statement in correct  syntax 


How can we pass a variable into a InfoPath form control ?

  

Hi there,

I have created a sharepoint (2007) sequential workflow using visual studio and as a task the user has to fill out an infopath form.

I would like to pass some text into a InfoPath form control. For example once the user open his InfoPath form task, a textbox control should be already fill out with values determined in the workflow code.

How can I achieve this ?For example in my workflow code I tried to set the values of the infopath control with ExtendedProperties. With this following code i can create a infopath task but i cannot fill the textbox control "Comments".

 

"Comments" is a datasource in my infopath.

 

  private void createReviewReadyTask_MethodInvoking(object sender, EventArgs e)

  {

   taskReviewReadId = Guid.NewGuid();

   taskReviewReadProperties.TaskType = 0;



   taskReviewReadProperties.AssignedTo 

pass datetime variable into execute sql task which has stored procedure

  

Hi all

I have a stored procedure something like this exec sp_name startdate, enddate. I have to run this in an ssis package.

The startdate and enddate values are loaded from a sql query, so i have declared variables (startdate,enddate) and got those values from the query using evaluateasexpression. Now, when i call the stored procedure in execute sql task it fails as the datatype from the variable is string and the stored procedure parameter (startdate,enddate) are datetime. Please help me.

The following are my settings in execute sql task editor

SQL statement : EXEC sp_name ?,?

parameter mapping

variablename: user::startdate

Direction: Input

data Type: Date

Parameter name : 0

Parameter size : -1

 


How do I pass a value from a ViewState into a ObjectDataSource parameter?

  

Hi there

Here is my code:

    public string DateBegin
    {
        get
        {
            if (null != ViewState["DateBegin"])
                return (string)ViewState["DateBegin"];
            else
                return DateTime.Now.ToUniversalTime().ToString("MM/dd/yyyy") + " 00:00:00 AM";
        }
        set
        {
            ViewState["DateBegin"] = value;
        }
    }

and:

		if (!Page.IsPostBack)
		{
            DateBegin = DateTime.Now.ToUniversalTime().ToString("MM/dd/yyyy") + " 00:00:00 AM";
...

Markup:

    <asp:ObjectDataSource ID="sourceJobHistory" runat="server"
        ...">
        <SelectParameters>
            <asp:Parameter Name="startRowIndex"  Type="Int32" />
            <asp:Parameter Name="pageSize"       Type="Int32"/>
            <asp:Parameter Name="sortExpression" Type="String" />    
            
            <!-- problem is to pass the value into here -->
            <asp:Parameter Name="DateBegin"  Type="String" />    
   
        </SelectParameters>
    </asp:ObjectDataSource>

Any ideas? Thank you!


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.

How to Pass Values Between Web Pages ASP.NET

  
You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

Use a query string.

Get HTTP POST information from the source page.

The following options are available only when the source and target pages are in the same ASP.NET Web application.

Use session state.

Create public properties in the source page and access the property values in the target page.

Get control information in the target page from controls in the source page.

How to Pass Values Between ASP.NET Web Pages

  
You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

Use a query string.

Get HTTP POST information from the source page.

The following options are available only when the source and target pages are in the same ASP.NET Web application.

Use session state.

Create public properties in the source page and access the property values in the target page.

Get control information in the target page from controls in the source page.

Retrieving a variable from a previous page

  

Hi,

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?


Thanks.


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?


Categories: 
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