Your question, your audience. Choose who sees your identity—and your question—with question security.
private List<string> DataSource
{
get
{
if (ViewState["DATASOURCE"] == null)
this.DataSource = new List<string>(new string[] { "Hello", "World", "Good Bye", "Sanity" });
return (List<string>)ViewState["DATASOURCE"];
}
set
{
ViewState["DATASOURCE"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.Repeater1.DataSource = DataSource;
this.Repeater1.DataBind();
}
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("deleteStation"))
{
this.DataSource.RemoveAt(e.Item.ItemIndex);
this.Repeater1.DataSource = DataSource;
this.Repeater1.DataBind();
}
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.