473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

dynamically generate multiView Problem

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"
Namespace="DBauer.Web.UI.WebControls"

TagPrefix="DBWC" %>

<html >

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

<title>Untitled Page</title>

</head>

<body>

<form id="sad" runat=server>

<dbwc:dynamiccontrolsplaceholder id="DynamicControlsPlaceholder1"
runat="server"

controlswithoutids="Persist"></dbwc:dynamiccontrolsplaceholder>

<br />

<br />

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

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

</form>

</body>

</html>

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

DynamicControlsPlaceholder1.Controls.Add(m)

Dim i As Integer

Dim v As View

For i = 0 To 5

v = New View

m.Views.Add(v)

v.ID = "MyView" & i

Dim txt As New TextBox

v.Controls.Add(txt)

txt.ID = "txt" & i

txt.Text = "My text " & i

Next

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),
MultiView).Views(1))

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),
MultiView).Views(2))

End Sub

End Class


May 7 '06 #1
0 3398

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fabuloussites | last post by:
I have a page that has multiview control that has two dropdown lists on it. the dropdown controls ARE NOT inside of the multiview. Each drop down is bound using its own sqldatasource conrtol. The...
0
by: Dianna | last post by:
Hi, I have a multiview that consists of 2 views. I am trying to put to buttons on the top so that the user can toggle between views. Problem: There does not seem to be any absolute...
0
by: Cetin | last post by:
Hi, I have a problem with the MultiView control. Hopefully you can help me. I made a asp page with a MultiView on it. The MultiView has three views (with some controls). I made a method that...
4
by: TMT32 | last post by:
Hi, I try to add multiview in datalist, but how to change multiview's default view page in datalist? Where it is ? datalist1.itemtemplates.itemtemplates.multiview ?? thanks TMT32
0
by: veerleverbr | last post by:
Hi, I want to create an asp.net page with a tabpage. On the tabpage I want to use the WebDateChooser and WebDataInput controls of Infragistics. These 2 controls use a mask to enter a date and...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
by: cvijaykrishna | last post by:
i am having a web based application and i am having a problem with it pls check it Explanationi am sending a sample code plese see it in VS-2005 FOR BETTER UNFERSTANDING I have a main page...
1
by: Nathan Sokalski | last post by:
When I include a MultiView control in my application, I receive the following error: MultiView cannot have children of type 'Label'. It can only have children of type View. I receive the...
0
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.