Hi.
I have a datatable where text entered in textbox will be saved in temporary data table,without sending to database.
Now,when i click at other menu in the page and click back at the temporary data table,the datatable will be cleared because it reloads when we click at any menus in the page.
I want the page to be static,without reload/refresh.The page is in content holder in master page.
Any ideas guys?
Loading

Bechir BejaouiRank #144 · 15.9K reputationPosted Sep 8, 2010, 6:32 PM EDT
Are using a gridview control to load data?
sam147 reputationPosted Sep 8, 2010, 6:36 PM EDT
Bechir BejaouiRank #144 · 15.9K reputationPosted Sep 9, 2010, 8:33 AM EDT
I can propose you more than one solution in that case. You can cache that data table. To cache the data table you have Session and Cache objects
To set caching
Session["yourdatatablename"] = yourdatatable
or
Cache["yourdatatablename"] = yourdatatable
To retrieve cache after several post backs use this syntax
DataTable table = (DataTable)Session["yourtablename"];
or
DataTable table = (DataTable)Cache["yourtablename"];
Use session to cache data for a unique user
Use cache to cache date for a set of users
You can use the View state to hold objects between postback too but in one situation. I mean when you're still making post back at the same page
Of Corse, you can bind your grid view to that cached data table instead of the normal data table
sam147 reputationPosted Sep 12, 2010, 5:11 PM EDT
Where do i apply this code?
This session and caching is new to me.
Bechir BejaouiRank #144 · 15.9K reputationPosted Sep 13, 2010, 3:07 AM EDT
http://aspalliance.com/1114_Understanding_the_Globalasax_file.all
The Cache could be defined as you like you can define it within the scope of the page if you want
sam147 reputationPosted Sep 17, 2010, 8:11 PM EDT
Based on your code,i do in this way :
but my data still dissapears when i click at another link and click at this table link back.
Is my code here right?
[code]
protected void Page_Load(object sender, EventArgs e)
{
{
if (!Page.IsPostBack)
{
//Instantiating the DataTable;
dt = new DataTable("Table1");
Session["Table1"] = dt;
//Adding Columns
dt.Columns.Add("name", typeof(string));
{
if (Session["Table1"] != null)
{
dt = (DataTable)Session["Table1"];
}
}
}
}
}
[/code]
Bechir BejaouiRank #144 · 15.9K reputationPosted Sep 18, 2010, 2:44 AM EDT
Add a global asax to your project, try to set the session there
http://aspalliance.com/1114_Understanding_the_Globalasax_file.all