Question

I have an asp:Repeater that is data bound to a collection of items once a button is clicked. Standard fare. However, if I DISABLE ViewState for the repeater, the time it takes to load the repeater after clicking the button takes dramatically longer. This is obviously the opposite of the effect I'm trying to achieve. By dramatic I mean ~10sec with ViewState enabled, and ~35sec with ViewState disabled.

I'm at a loss...

NOTE: In the event handler for the button click, I am also caching the data source. I am doing this regardless of whether I enable/disable ViewState. Is it possible that my caching is being ignored when ViewState is being used?

Here's the relevant code:

<asp:repeater id="niinMatchesTable" runat="server" enableviewstate="false">
<headertemplate>
<table id="niinMatches" class="listing alternate">
  <tr>
    <th>QTY.</th>
    <th><asp:linkbutton runat="server" onclick="sortResultsTable" commandargument="niin-niin" text="NIIN" /></th>
    <th><asp:linkbutton runat="server" onclick="sortResultsTable" commandargument="niin-partnumber" text="PART #" /></th>
    <th>Cases</th>
  </tr>
</headertemplate>
<itemtemplate>
<tr class="odd">
  <td><asp:label runat="server" text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' /></td>
  <td><asp:label runat="server" text='<%# DataBinder.Eval(Container.DataItem, "NIIN") %>' /></td>
  <td><asp:label runat="server" text='<%# DataBinder.Eval(Container.DataItem, "PartNumber") %>' /></td>
  <td><asp:label runat="server" text='<%# DataBinder.Eval(Container.DataItem, "Cases") %>' /></td>
</tr>
</itemtemplate>
<footertemplate>
  </table>
</footertemplate>
</asp:repeater>



protected void uploadClick(object sender, EventArgs e)
{
    if (fileUploader.HasFile)
    {   
        fileUploader.SaveAs(Server.MapPath("~/temp/inventory.xls"));
        var niinMatches = getNiinMatches(); // Populates object by parsing spreadsheet

        var absExp = System.Web.Caching.Cache.NoAbsoluteExpiration;
        var slidingExp = TimeSpan.FromMinutes(10);
        Cache.Insert("_niinMatches", niinMatches, null, absExp, slidingExp);

        niinMatchesTable.DataSource = niinMatches;
        niinMatchesTable.DataBind();
    }
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top