troubleshooting Question

How to preserve large data on postback without loading it again

Avatar of luefher
luefherFlag for United States of America asked on
.NET ProgrammingASP.NET
4 Comments1 Solution719 ViewsLast Modified:
Hello,

I have a page with a table in UpdatePanel that is dynamically populated with a large amount of data, takes some time to retrieve. The table has LinkButtons in it to drill-down on that data, which is then displayed in a hide/show div. Problem is, since it's a postback, the original data has to be retrieved again - I'm trying to avoid this since it takes time but it's the same data that was retrieved before postback - I just want to retrieve the drilled-down data and show it. If I put the retrieval of initial data in (!IsPostBack), then it, of course is not retrieved on postback and is not showed. Is there some kind of a workaround?
Thanks!
<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
        ...
        <asp:Table ID="TableData" runat="server">
        </asp:Table>
        <div id="...>
            <asp:Table ID="TableDrillDown" runat="server">
            </asp:Table>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
 
 
protected void Page_Load(object sender, EventArgs e)
{
    this.PopulateData();
}
 
private void PopulateData()
{
    // here we retrieve a large amount of data
    ...
    // then populate table
    ...
    // adding LinkButtons along the way
    TableRow tr = new TableRow();
    TableCell td = new TableCell();
    LinkButton lb = new LinkButton();
    lb.ID = linkButtonId;
    lb.Text = someDataValue;
    lb.CommandName = "drill-down";
    lb.CommandArgument = someArgs;
    lb.Command += this.LinkButton_DrillDownCommand;
    td.Controls.Add(lb);
    tr.Cells.Add(td);
    this.TableData.Rows.Add(tr);
    ...
}
 
protected void LinkButton_DrillDownCommand(object sender, CommandEventArgs e)
{
    // Populate drill-down table here
    TableRow tr = new TableRow();
    TableCell td = new TableCell();
    td.Text = someDataValue;
    tr.Cells.Add(td);
    this.TableData.Rows.Add(tr);
    ...
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros