macros14
asked on
asp:table loses data
I have a asp:table that I put on my aspx page. I then on page_load create some rows for it. Everything works fine and the table displays, but I do other processing on the page where I need to postback, so when I hit a button to postback, the table is gone, even though I have enableviewstate set to true. Is there a way to display the table so I don't have to recreate it on every postback?
In your Page_Load Event write(first line in this sub):
C#:
if (Page.IsPostBack)
return;
VB.NET:
If (Page.IsPostBack) Then Exit Sub
C#:
if (Page.IsPostBack)
return;
VB.NET:
If (Page.IsPostBack) Then Exit Sub
ASKER
I don't want to create the table everytime on postback, it takes awhile to process, is there a reason why enableviewstate isn't working with the table?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
private void Page_Load(object sender, System.EventArgs e)
{
FillTable(); //must be outside of !Page.IsPostback so it fires each time
if( !Page.IsPostback)
{
//do whatever
}
}
private void FillTable()
{
//code to create table
}