ASP (.NET 4) Literal control not retaining changes to HTML contents on
PostBack
I am populating a ListView with HTML from a database using a Literal with
Text='<%#Eval("Data")'%>. When I trigger a PostBack, changes to the loaded
HTML are not being reflected in litRowData.Text.
ViewState is enabled for the page, the ListView, and the Literal in the
ItemTemplate, and I am making sure to only populate the ListView with
initial values from the database when if(!IsPostBack) is true in
Page_Load.
<asp:ListView ID="lvIntermediateSanctions" runat="server"
DataKeyNames="RowID" ItemPlaceholderID="phRow"
EnableViewState="true">
<LayoutTemplate>
<asp:PlaceHolder ID="phRow" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<asp:Literal ID="litRowData" runat="server" Text='<%#Eval("Data")%>'
EnableViewState="true"></asp:Literal>
</ItemTemplate>
</asp:ListView>
I need to be able to capture changes to the contents of the loaded HTML
controls. Since this HTML comes from a database table, I can't just use
ASP controls inside the ItemTemplate. Can anyone see something I'm
missing, or suggest an alternative way to do this?
No comments:
Post a Comment