Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need to create web page that has content in grid view or data grid. (the control is similar to an excel sheet). After entering some data in this i need to continue filling the data in a second web page which has some text boxes and added details. I plan this to do with a link or button "Next".
After entering the data in the second web page i wish to come back to review what i have filled.
and then finally click a save button that will put the data in the two forms to one table.

please help me find out a solution to keep the content in the grid when i click next and then come back to the same page. on coming back to the page i should have the values entered previously.

In windows i had solved this issue by not letting another instance(object) of the created form be allowed.
As i am new to ASP i cant figure out how to solve this issue. conceptually i dont want another instance of that page be created till i am logged in.
Posted

Hi,

Upto my knowledge you can save your first page data in session variable like


C#
DataTable dt=new DataTable();
dt.rows[0][0]=(gridView.rows[0].findcontrol("TextBox")).Text;
//..
//..
 Session["frstdata"]=dt;
response.redirect("nextpage.aspx");


place this type of code in next button click event

After entering into next page you can retrieve first page information in second page or any where

like

C#
DataTable dt=(DataTable)Session["frstdata"];
//you can use this table data 


You can try this way .If user didn't save that data its just cleared after user's session timeouts

I hope you understood What I said

All the Best
 
Share this answer
 
Hi,

There is a control in .net called "create user wizard" in that control all those features you mentioned in your question are present there by default.Basically this controls is used for user registration forms and all, but you can exploit its properties according to your requirements.

You can visit the below link on more details about this control

http://www.4guysfromrolla.com/articles/050609-1.aspx[^]


I think this will help you out.


Happy coding!!!
 
Share this answer
 
Hi Muralikrishna8811
it can be done by keeping it in session variable and then returning it back as a session variable.
But i feel this as a overhead as i not only grid but also some other controls which i want to keep. I will do this if i am not able to find any other option.

sujit0761,
i couldn't find the create user wizard,
but i have found a control called "wizard" with the hint of finding create user wizard.


This is exactly what i need.
Thanks.
 
Share this answer
 
Those controls should be views on some model data in the user space (generally that means in the session for web apps). Simply putting the DataTable into the session as Murali suggests is the simplest kind of 'model', and perfectly fine for a grid (an alternative might be a List<T> if the grid represents a series of rows).

Your grid control should expose a property similar to DataSource – to which you can assign an entire data source, or from which you can read it back. (Your question isn't clear as to whether this is a custom grid control.) Then, when you receive a postback, store the results of this page in the session:

class Page1State {
 public DataTable table;
 public string Name, Email;
 // etc ... all the data for this page
}

...

private void OnSubmit(object sender, EventArgs e){
 Page1State state = new Page1State();
 state.table = gridView1.DataSource as DataTable;
 state.Name = nameTextBox.Text;
 state.Email = emailTextBox.Text;
 // etc
 Session["FirstPageState"] = state;
}

private void OnPageLoadobject sender, EventArgs e){
 Page1State state = Session["FirstPageState"] as Page1State;
 if(null != state){
  gridView1.DataSource = state.table;
  // etc
 }
}
 
Share this answer
 

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