I have this code which adds a x number of views to a Multiview control. The Multiview control exist on the page with only one view. on page init I create x number of views with a GridView control added to each of these views when I come to loop through to find which one I want to show the Multiview control says it has only 1 view.

```
    protected void variantRepeat_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandSource.GetType() == typeof(LinkButton))
        {
            string theID = ((LinkButton)e.CommandSource).CommandArgument.ToString();
            ViewCollection views = prodView.Views; //this has only 1 view the one that has been added on the source view of the .aspx page
            foreach (View toDisplay in views)
            {
                if (toDisplay.ID == theID)
                    prodView.SetActiveView(toDisplay);
            }
        }

    }

```

The code above loops to find the view and display it. Why do all the views disappear, I've stepped through and at init and after it has finished processing database queries it has x number of views > the 1 in source view.

Why does this control "lose" the views?

Init code:

```
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString == null || Request.QueryString.Count < 1)
            Response.Redirect(Server.MapPath("~/Packages/"));
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"].ToString() == string.Empty)
                Response.Redirect(Server.MapPath("~/Packages/"));
            var id = Server.HtmlEncode(Request.QueryString["id"].ToString());
            Guid packID = Guid.Parse(id);
            using (var context = new GaleEntities())
            {
                var thePackage = context.PackageEnts.First(p => p.packageID == packID);
                var theVariants = thePackage.Variants;
                var mydatasource = new List<PackageEnt> { thePackage };
                var myVariantDataSource = new List<Variant>();
                foreach (Variant single in theVariants)
                {
                    myVariantDataSource.Add(single);
                }
                packageForm.DataSource = mydatasource;
                variantRepeat.DataSource = myVariantDataSource;
                RenderProductGridviews(theVariants);
                prodView.SetActiveView(prodView.Views[0]);
            }
            packageForm.DataBind();
            variantRepeat.DataBind();
            Page.DataBind();
        }
    }

    protected void RenderProductGridviews(System.Data.Objects.DataClasses.EntityCollection<Variant> variantCol)
    {
        foreach (Variant packVar in variantCol)
        {

            View newView = new View();

            GridView prodGrid = new GridView();
            var myProdDataSource = new List<vw_VariantProduct>();             
            using (var context = new GaleEntities())
            {
                var singleProd1 = context.vw_VariantProduct.Where(vp => vp.variantID == packVar.variantID);
                foreach (vw_VariantProduct extProd in singleProd1)
                {
                    myProdDataSource.Add(extProd);
                }
            }
            prodGrid.DataSource = myProdDataSource;

            BoundField _column = new BoundField();
            _column.DataField = "product_title";
            _column.HeaderText = "Product";
            prodGrid.Columns.Add(_column);

            _column = new BoundField();
            _column.DataField = "product_title";
            _column.HeaderText = "Product";
            prodGrid.Columns.Add(_column);

            _column = new BoundField();
            _column.DataField = "product_desc";
            _column.HeaderText = "Description";
            prodGrid.Columns.Add(_column);

            _column = new BoundField();
            _column.DataField = "product_time";
            _column.HeaderText = "Time (mins)";
            prodGrid.Columns.Add(_column);

            _column = new BoundField();
            _column.DataField = "quantity";
            _column.HeaderText = "Quantity";
            prodGrid.Columns.Add(_column);

            prodGrid.DataBind();
            newView.ID = packVar.variantID.ToString();
            newView.Controls.Add(prodGrid);
            prodView.Views.Add(newView);
        }
    }

```