By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,319 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,319 IT Pros & Developers. It's quick & easy.

dynamically generate multiView Problem

P: n/a
Hi friends,

I am very sorry for my not perfect English.

I have one question, I am using David Bauer's DynamicControlsPlaceholder to
dinamically generate controls and I am tryig to generate MultiViev, at first
it working, when I click btn1 I set SetActiveView to viev1 and it's working
OK, but when after that I click btn2 and try to set SetActiveView to 2, I
receive this error:

ActiveViewIndex is being set to '1'. 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

Please help me to understand this error

This is my code

Aspx file:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="test" title="Untitled Page" %>

<%@ Register Assembly="DBauer.Web.UI.WebControls.DynamicControl sPlaceholder"

TagPrefix="DBWC" %>

<html >

<head id="Head1" runat="server">

<title>Untitled Page</title>



<form id="sad" runat=server>

<dbwc:dynamiccontrolsplaceholder id="DynamicControlsPlaceholder1"


<br />

<br />

<asp:Button ID="btn1" runat="server" Text="first click here" />

<asp:Button ID="btn2" runat="server" Text="then click here" />




Vb file:

Partial Class test

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then

Dim m As New MultiView


Dim i As Integer

Dim v As View

For i = 0 To 5

v = New View


v.ID = "MyView" & i

Dim txt As New TextBox


txt.ID = "txt" & i

txt.Text = "My text " & i


End If

End Sub

Protected Sub btn1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn1.Click

DirectCast(DynamicControlsPlaceholder1.Controls(0) ,
MultiView).SetActiveView(DirectCast(DynamicControl sPlaceholder1.Controls(0),

End Sub

Protected Sub btn2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn2.Click

DirectCast(DynamicControlsPlaceholder1.Controls(0) ,
MultiView).SetActiveView(DirectCast(DynamicControl sPlaceholder1.Controls(0),

End Sub

End Class

May 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.