Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my Default2.aspx.cs page........


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }
    protected void btnsave_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new System.Data.DataColumn("Name", typeof(String)));
        dt.Columns.Add(new System.Data.DataColumn("Address", typeof(String)));
        dt.Columns.Add(new System.Data.DataColumn("Cell", typeof(String)));
        if (ViewState["CurrentData"] != null)
        {
            for (int i = 0; i < +1; i++)
            {
                dt = (DataTable)ViewState["CurrentData"];
               
            }
            dr = dt.NewRow();
          Application["dr[0]"] = TextBox1.Text;
          Application["dr[1]"] = TextBox2.Text;
          Application["dr[2]"] = TextBox3.Text;
            dt.Rows.Add(dr);
            Response.Redirect("Default3.aspx");

        }
       
    }
}



this is my Default3.aspx.cs page........


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        if (ViewState["CurrentData"] != null)
        {
          GridView1.DataSource = (DataTable)ViewState["CurrentData"];
            GridView1.DataBind();
        }
        ViewState["CurrentData"] =dt;

    }
}
Posted
Updated 15-Mar-12 19:33pm
v2
Comments
ProEnggSoft 16-Mar-12 1:34am    
Edit: pre tag for C# code added - PES
rockpune 16-Mar-12 1:38am    
am newly learning plz tell me how can i do that

1 solution

1. on your page 2 where are you putting the data in viewstate object. you are checking for null and then not doing if it is null.

2. my suggestion

in default2.aspx

if(Application["CurrentData"] == null)
{
 Application["CurrentData"] = dt;

}


in default3.aspx

GridView1.DataSource = (DataTable)Application["CurrentData"];
 
Share this answer
 
Comments
rockpune 16-Mar-12 3:34am    
i tryed still not getting sir..........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900