using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class StateDemo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            List<string> stringList = new List<string>();
            stringList.Add("Łańcuch Pierwszy");
            stringList.Add("Łańcuch Drugi");
            stringList.Add("Łańcuch Trzeci");
            StateControl1.DataSource = stringList;
            StateControl1.SelectedIndex = 2;
        }
        StateControl1.DataBind();
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        Response.Write("Wymaga stanu kontrolki: " + RequiresControlState(StateControl1) + "<br/>");
    }

    protected void button1_Click(object sender, EventArgs e)
    {
        Response.Write("Naciśnięto przycisk, to jest formularz zwrotny.<br/>");
        Response.Write("Wybrany indeks kontrolki StateControl: " + StateControl1.SelectedIndex.ToString() + "<br/>");
    }
}
