I have the a ListView
like this
<asp:ListView ID="ListView1" runat="server">
<EmptyDataTemplate>
<asp:Literal ID="Literal1" runat="server" text="some text"/>
</EmptyDataTemplate>
...
</asp:ListView>
In Page_Load()
I have the following:
Literal x = (Literal)ListView1.FindControl("Literal1");
x.Text = "other text";
but x
returns null
. I’d like to change the text of the Literal
control but I don’t have no idea how to do it.
Best Answer
I believe that unless you call the
DataBind
method of yourListView
somewhere in code behind, theListView
will never try to data bind. Then nothing will render and even theLiteral
control won’t be created.In your
Page_Load
event try something like: