Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-12-2008
Member
 
Join Date: Dec 2008
Posts: 19
how to pass the dataset from one page to another page in Asp.Net

Hi,

i am developing the project in Asp.Net using C#.
for this i want to pass dataset from one page to another page, but i am not getting this.

will you please help me?

Thanks.
Reply With Quote
  #2  
Old 27-12-2008
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: how to pass the dataset from one page to another page in Asp.Net

You can store your DataSet in Session since you need to use it in other pages. That way you can use the value of Session, cast it as a Dataset and use it as your DataSource.


DataSet ds = //Set DataSource
Session["key"] = ds;

//Then on Page2.aspx use this codes below to use the DataSet stored in Session

if (Session["key"] != null)
{
DataSet dsCurrent = (DataSet)Session["key"];
GridView1.DataSource = dsCurrent;
GridView1.DataBind();
}
Reply With Quote
  #3  
Old 27-12-2008
Member
 
Join Date: May 2008
Posts: 2,008
Re: how to pass the dataset from one page to another page in Asp.Net

If you need to pass small amounts of data from one page to another, you can pass it in the query string and the target page can retrieve it through Request.QueryString collection (GET operation).

However, if you need to pass large amount of data you cannot pass it in the query string since Internet Explorer has maximum 2048 character limit on the address of the page. In these cases, you can pass data from one page to another using POST operation.

In your source page, define a hidden variable to hold the data to pass and pass only its ID to the target page in the query string.
Reply With Quote
  #4  
Old 27-12-2008
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: how to pass the dataset from one page to another page in Asp.Net

you can use the following code,

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class PL_Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CreateDataSet();
}
}
private void CreateDataSet()
{
DataSet ds = objTest.GetSource();
Session["sessDataSet"] = ds;
}
}

Default3.aspx

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class PL_Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetValues();
}
}

private void GetValues()
{
if (Session["sessDataSet"] != null)
{
DataSet ds = (DataSet)Session["sessDataSet"];
//Here we can use the Session Value ds
}
}
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "how to pass the dataset from one page to another page in Asp.Net"
Thread Thread Starter Forum Replies Last Post
IE 9 is displaying blank page and showing links as mouse hovered on the page Chitti's Technology & Internet 10 03-12-2011 10:31 AM
How can I get speed dial page as default page in Google Chrome v13 ? Shurod Technology & Internet 6 12-09-2011 10:47 PM
Getting ?Page cannot be displayed? error message while loading page on Internet Explorer 9 Nabhan Technology & Internet 9 26-08-2011 11:44 AM
Unable to retrieve page in kindle based on page numbers rUChIRr Portable Devices 6 08-07-2011 10:02 PM
How to Pass data from one page to another in PHP? Aldous Software Development 3 25-09-2009 03:21 PM


All times are GMT +5.5. The time now is 04:21 AM.