Changing property of ItemTemplate controls in ListView
- by arturito
I have ListView containig LinkButtons in ItemTemplate. ListView is inside UpdatePanel so it is not doing page refresh.
When users click on one the LinkButtons it changes its css property in order to mark the selection:
protected void ListView1_ItemCommand1(object sender, ListViewCommandEventArgs e)
{
((LinkButton)e.CommandSource).CssClass = "selected";
}
That allows multiple selections. But once the page is refreshed the selection disappears, meaning that
css property of control goes back to default.
<ItemTemplate>
<asp:LinkButton ID="local"
Text='<%#Eval("Local.Name")%>'
runat="server"
CommandName="selectLocal"
CommandArgument='<%#Eval("Local.Id") %>'
CssClass="notSelected"
>
</asp:LinkButton>
<asp:LinkButton ID="guest"
Text='<%#Eval("Guest.Name")%>'
runat="server"
CommandName="selectGuest"
CommandArgument='<%#Eval("Guest.Id") %>'
CssClass="notSelected"
>
</asp:LinkButton>
</ItemTemplate>
How can I select them programatically on page reload?
(I'm mainating selection list in session)