473,387 Members | 1,463 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,387 software developers and data experts.

Why is an Index out of range when deriving from TreeView?

Help!!!

//
// Contents of ValueNode.cs
//

using System;

using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for ValueNode.
///
/// Warning: Use of this class may cause hypertension and various neurotic
disorders.
///
/// </summary>
public class ValueNode : TreeNode
{
public ValueNode() : base()
{
Text = "value";
}
}
}
//
// Contents of XNode.cs
//
using System;
using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for XNode.
/// </summary>
public class XNode : TreeNode
{
public XNode() :base()
{
}
public XNode(string XStr) :base()
{
Text = XStr;
if(XStr == "Works")
{
TreeNode n = new TreeNode();
n.Text = "value";
Nodes.Add(n);
}
else
{
ValueNode n = new ValueNode();
Nodes.Add(n);
}
}
}
}

//
// Contents of WebForm1.aspx.cs
//

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//
//
// Added Line:
using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView tv;

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
tv.AutoPostBack = true;
//
tv.Nodes.Add(new XNode("Works"));
//tv.Nodes.Add(new XNode("DoesNotWork"));

}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
The WebForm1.aspx file HTML

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="TreeNodeProblem.WebForm1" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<iewc:TreeView id="tv" style="Z-INDEX: 101; LEFT: 288px; POSITION:
absolute; TOP: 200px" runat="server"></iewc:TreeView>
</form>
</body>
</HTML>

--
Be Positive Every Day
Apr 11 '06 #1
1 1937
What line is the exception coming from? You need to give some more
specifics.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

"David" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:1jP_f.500$iF3.77@dukeread01...
Help!!!

//
// Contents of ValueNode.cs
//

using System;

using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for ValueNode.
///
/// Warning: Use of this class may cause hypertension and various
neurotic disorders.
///
/// </summary>
public class ValueNode : TreeNode
{
public ValueNode() : base()
{
Text = "value";
}
}
}
//
// Contents of XNode.cs
//
using System;
using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for XNode.
/// </summary>
public class XNode : TreeNode
{
public XNode() :base()
{
}
public XNode(string XStr) :base()
{
Text = XStr;
if(XStr == "Works")
{
TreeNode n = new TreeNode();
n.Text = "value";
Nodes.Add(n);
}
else
{
ValueNode n = new ValueNode();
Nodes.Add(n);
}
}
}
}

//
// Contents of WebForm1.aspx.cs
//

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//
//
// Added Line:
using Microsoft.Web.UI.WebControls;

namespace TreeNodeProblem
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView tv;

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
tv.AutoPostBack = true;
//
tv.Nodes.Add(new XNode("Works"));
//tv.Nodes.Add(new XNode("DoesNotWork"));

}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
The WebForm1.aspx file HTML

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="TreeNodeProblem.WebForm1" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<iewc:TreeView id="tv" style="Z-INDEX: 101; LEFT: 288px; POSITION:
absolute; TOP: 200px" runat="server"></iewc:TreeView>
</form>
</body>
</HTML>

--
Be Positive Every Day

Apr 12 '06 #2

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

Similar topics

4
by: Biff | last post by:
Is there a common way to check for vector indexes being in bounds? My version of the STL has no such check, even in debug builds. I was considering deriving a class from Vector with its own...
14
by: Craig O'Shannessy | last post by:
Hi all, Just thought I'd mention that I really think this problem needs to be fixed. I I'm patching the 7.4RC1 JDBC drivers as we speak due to this optimiser bug, and it's the third time...
3
by: Kelvin Bryant | last post by:
I have tried the following code to set the index for a node. It seems to work when I use the root node index of 0. When I try a number greater than 0 I get an out of range error. I made sure that...
2
by: kscdavefl | last post by:
When I run the following code: private void applicationPermissionGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType ==...
1
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to...
35
by: erikwickstrom | last post by:
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. ...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello As I debug the C# code with a break point and by pressing F11 I eventually get a message stating: ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from...
6
by: shashi shekhar singh | last post by:
Respected Sir, I am facing problem when i try to deploy my website on iis 7.0 on test page. i have to display some .mht files on iframe in gridview and error looks like below, Server Error in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.