locked
Enum , ActiveViewIndex from Multiview/views problems RRS feed

  • Question

  • User-2006371901 posted


    I have a multiview that houses 9 views , which are powered by datagrids. The ActiveViewIndex gets the value from the enum lineup

    enum TabPages : int
            {
     Test = 0,
             First= 1,
     Second = 2,
             Third = 3,                       
            }
    ...this checks to see if the page clicked was in the lineup:
    if (mvTabViews.ActiveViewIndex == (int)TabPages.Third)

    ...and this sets the selected tab value:
     
                int nSelectedTab = Convert.ToInt16(e.Item.Value);

    ...the other datagrids I have work, they display when the appropriate menu item is clicked. When I click on the one that is wired to the Third value, i get the error :
    System.ArgumentOutOfRangeException: ActiveViewIndex is being set to '3'.  It must be smaller than the current number of View controls '3'. For dynamically added views, make sure they are added before or in Page_PreInit event.

    i'm not sure how to deal with the Page_PreInit event, as right now (I'm not the author of the code) the Page_PreInit event just initiates a master page for the mobile view of the application. All my other tabs on the menu work fine except this one on the Third
    ??
    Ned

    Tuesday, June 4, 2019 7:14 PM

All replies

  • User475983607 posted

    The error seems pretty clear.  The code is trying to access a View index that does not exist.  

    We can't see the code so that's about all the help we can provide.

    Tuesday, June 4, 2019 7:19 PM