Results 1 to 4 of 4

Thread: how to pass the dataset from one page to another page in Asp.Net

  1. #1
    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.

  2. #2
    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();
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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
    }
    }
    }

Similar Threads

  1. Replies: 10
    Last Post: 03-12-2011, 10:31 AM
  2. Replies: 6
    Last Post: 12-09-2011, 10:47 PM
  3. Replies: 9
    Last Post: 26-08-2011, 11:44 AM
  4. Unable to retrieve page in kindle based on page numbers
    By rUChIRr in forum Portable Devices
    Replies: 6
    Last Post: 08-07-2011, 10:02 PM
  5. How to Pass data from one page to another in PHP?
    By Aldous in forum Software Development
    Replies: 3
    Last Post: 25-09-2009, 03:21 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,480,972.64936 seconds with 16 queries