I have a ListView control that exhibits odd behavior - rows are only partially updated after postback. I hope someone here can shed light on why this might happen.
My listview DataSource is tied to a list of items that is stored in the page session state. This is intentional, in part for the timeout of outdated views, as several users view the data. In a simple resort, sorting is processed on the page via javascript, and the order of the list / session data is stored synchronously via callbacks. The callback also checks permission levels. On a specific complex resort operation, javascript on the page makes a link back to the page to process the sorting logic. The list / session is updated, as in the callback, then the listview control returns to the data. The page loads again, and the lines show a new order. No problem, right?
The problem is that some items in the list do not change the value in accordance with the new order. Although hyperlinks and text processed on the page (for example, <% # Eval ("ProjectAbbrev")%>) are updated accordingly, flags, literals, and drop-down lists that have their values set using the OnItemDataBound event method are not - they remain “frozen” in place, even though passing through the code reveals that the method is being executed during the postback and that the controls MUST be set to their new values. If I go away and manually truncate the list to say half the original size, it’s enough that only those elements are kept secret, but the checkboxes still retain their original values.
So my question is: why aren't these items updated with the rest of the listview controls when posting back? I have the feeling that I either misunderstand the page life cycle in ASP.NET, or that I encountered some kind of error.
At this point, I think I will have to move the more complex sort operation to a page in javascript, but it will be quite complicated, and I would like to avoid this if possible.
UPDATE: I tried to set EnableViewState to false and this does not fix. I could not use this tactic in any case, because other parts of the page (except) rely on reading the viewstate at the end.
UPDATE: I provide some code snippets in the hope that they can shed light on this issue:: HyperLink , CheckBox, OnQueueRepeater_ItemDataBound, .
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TextProcessorProjects.ascx.cs" Inherits="ETD.UI.Controls.TextProcessorProjects" %>
<asp:ListView ID="QueueListView" runat="server" OnItemDataBound="OnQueueRepeater_ItemDataBound">
<ItemTemplate>
<tr>
<td><asp:HyperLink runat="server" ID="ProjectIDLink"><%# Eval("ProjectAbbrev") %></asp:HyperLink></td>
<td><asp:CheckBox runat="server" ID="ScannedCheckBox" BorderStyle="None" /></td>
</tr>
</ItemTemplate>
</asp:ListView>
: :
protected List<Book> QueueDataItems
{
get { return (List<Book>)Session["Queue"]; }
set { Session["Queue"] = value; }
}
else if (IsPostBack && !Page.IsCallback)
{
ResortQueue(Request.Params)
QueueListView.DataSource = QueueDataItems;
QueueListView.DataBind();
}
protected void OnQueueRepeater_ItemDataBound(object sender, ListViewItemEventArgs e)
{
CheckBox scannedCheckBox = e.Item.FindControl("ScannedCheckBox") as CheckBox;
scannedCheckBox.Checked = book.Scanned;
}
UPDATE: , , javascript. - - , , !