Using ViewState, start-to-end I'm learning ASP.NET and think I figured out ViewState. Can you tell me if I have it right?

The goal of the ViewState in this page is simply to keep the value in a DropDownList.

So first, let's have the aspx page markup:

&lt;%@ Page Title="Parameters" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ParamPage.aspx.cs" Inherits="MyCompany.MyProject.WebGUI.ParamPage" %&gt;

...

&lt;asp:DropDownList ID="UserList" runat="server" AutoPostBack="True" Width="125px" OnSelectedIndexChanged="UserList_SelectedIndexChanged"&gt;&lt;/asp:DropDownList&gt;


In Page_Load, the list is populated:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
        BindUserList(); //Just to give an idea
}


I store the selection in a property which uses the ViewState:

protected string SelectedUser
{
    get { return (string)ViewState["SelectedUser"]; }
    set { ViewState["SelectedUser"] = value; }
}


The property is set when the selected index is changed:

protected void UserList_SelectedIndexChanged(object sender, EventArgs e)
{
    if (UserList.SelectedIndex == -1)
        SelectedUser = null;
    else
        SelectedUser = UserList.Text;
}


And I need to override the SaveViewState() and LoadViewState() functions fromPage`:

protected override object SaveViewState()
{
    object baseState = base.SaveViewState();
    string user = UserList.Text;
    return new object[] { baseState, user};
}

protected override void LoadViewState(object savedState)
{
    if (savedState != null)
    {
        object[] stateObjects = (object[])savedState;
        if (stateObjects[0] != null)
            base.LoadViewState(stateObjects[0]);
    }
}


And, in order to re-select the right user, in BindUserList, I do this:

private void BindUserList()
{
    //... get and bind list
    if (UserList.Items.Count &gt; 0)
    {
        var item = UserList.Items.FindByText(SelectedUser);
        if (item != null)
            item.Selected = true;
    }
}


Is this the proper way to use ViewState? Am I missing something that would make this unsafe? Am I doing anything superfluous?
You don't have to maintain the DropDownList's seelcted item becouse it will do it by it's self. The problem will only occur when you have disabled the ViewState for the control.