manage multiview control

I'm developing a web page - ( .net 3.5 - visual studio 2008 ) :

This is my idea :
I need to add Controls to a web form page programmatically (labels, textboxes, ect..)

Controls must be grouped into "Sections".
I Inserted a Multiview into my page.
When I load the page, I retrieve information about controls in a database.
Then I create a view and add it to multiview control and so add controls to each view.
Now I want display my "sections" like tab strips :

My code (more or less) :

protected void Page_PreInit(Object sender, EventArgs e)
if (!IsPostBack)
this.MultiViewSections.ActiveViewIndex = 0;

private void ChargeControls()

read database table

for each record


viewSection = new View();
viewSection.ID = "Section" ;
int indexSection = 0 ;

label = new Label();
label.ID = "lblSection" ;
label.Text = "text Section";



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"

Inherits="WebApplication.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"




I can see first view
( this.MultiViewSections.ActiveViewIndex = 0; ).
But I can't navigate to others views , I get this error :
ActiveViewIndex is being set to '0'. It must be smaller than the current number of View

controls '0'.
For dynamically added views, make sure they are added before or in Page_PreInit event.

Parameter name: value

I inserted two buttons into the page and I try to use these instructions :
NextView/PrevView , SwitchViewByID, MultiView1.ActiveViewIndex += 1 / -= 1 .
No result!

what's wrong ?
Thanks in advance .

A MultiView control is a good choice in this situation ?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!