Quote:
...WebForms...
List<hyperlinks> hll = new List<hyperlinks>();
It looks like you're storing your list as a field within your page. That won't work in WebForms - every time the user causes a post-back, a new instance of your page class is created, so the list will be empty.
If you want to persist the value between requests, you either need to store it in the session:
private List<hyperlinks> hll
{
get
{
var value = (List<hyperlinks>)Session["hll"];
if (value == null)
{
value = new List<hyperlinks>();
Session["hll"] = value;
}
return value;
}
}
or store it in the form somehow - the usual approach is to use
ViewState
:
private List<hyperlinks> hll
{
get
{
var value = (List<hyperlinks>)ViewState["hll"];
if (value == null)
{
value = new List<hyperlinks>();
ViewState["hll"] = value;
}
return value;
}
}