Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 August 27th, 2006, 04:53 PM
Authorized User
 
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Items.Context with Server.Transfer

Hello and thank you for taking a moment to read this message. I am trying to use Items.Context (from HttpCollection) with Server.Transfer to pass the selected value of a asp dropdown box( autopostback="True") to a second web page. The value I want passed is essentially an order number. The second webpage will display a datagrid with information about the order number passed. I am using 1.1 framework. The relevant Code Behind for the 1st page( the page passing the value) is this:


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

private void DropListChanged(Object sender,EventArgs e)

{//Storing in Context

Context.Items("OrderID") = DropDownList1.SelectedItem;

Server.Transfer("ordergrid.aspx");

}


--------------------------------------------------------------------------------
I then want to pass the value as a parameter to my stored procedure on the second page to make the data grid work:
--------------------------------------------------------------------------------

//Get the connection string from the web config and open the connection

SqlConnection dbConn = new SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings["NWind"].ToString());

dbConn.Open();

//Get your sql command utilizing the stored procedure


SqlCommand sqlCom = new SqlCommand("usp_retrieve_order_info");

sqlCom.CommandType = CommandType.StoredProcedure;

sqlCom.Parameters.Add("@OrderID",Context.Items("Or derID") );



sqlCom.Connection = dbConn;



//declare a new dataset


DataSet ds = new DataSet();

//declare the adapter to fill the dataset


SqlDataAdapter da = new SqlDataAdapter(sqlCom);



//Fill dataSet DS with results set and name the filled table "tblOrders"


da.Fill(ds, "tblOrders");

//Bind the the dataset to our datagrid

dgrdOrders.DataSource =ds;

dgrdOrders.DataBind();


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

The problem is that VS looks at the code I have in bold above, it keeps throwing me the error: c:\inetpub\wwwroot\NOrders\ordergrid.aspx.cs(37): 'System.Web.HttpContext.Items' denotes a 'property' where a 'method' was expected

I know that you can use thisContext.Items to pass data but I'm just not sure what I'm doing wrong. I have spent a considerable amount of time reading up on the HttpContext class, but to no avail. If there is any one who can help me gain a better understanding on the process I would be greatly appreciative. Thank you in advance.

Jason








Similar Threads
Thread Thread Starter Forum Replies Last Post
CH 15 Context Menu - Element Menu Items Razzy The Pug BOOK: Ivor Horton's Beginning Visual C++ 2005 2 November 9th, 2008 03:53 PM
example of Server.Transfer and Context Handler hanusoft ASP.NET 1.x and 2.0 Application Design 0 September 5th, 2007 11:53 PM
Server.Transfer Sheraz Khan ASP.NET 2.0 Basics 1 July 28th, 2007 05:17 AM
Assigning Context.Items Value To SQL Query arsicles ASP.NET 1.0 and 1.1 Basics 1 April 20th, 2006 01:45 PM
Transfer Data from one server to another server Jane SQL Server 2000 2 February 28th, 2005 03:15 AM





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