[2005] Treeview error Specified argument was out of the range of valid values.

Hi,

I am getting a Specified argument was out of the range of valid values. - Parameter name: index, ERROR when I click on a dynamically created treeview control in my asp.net (Framework 2) web page. The treeview populates as expected but when clicking on the child node I get the above mentioned error. I also have a ajax panel control on the same page but the tree view is not on any of the panels but in a seperate table cell on the same page. I only mention this as the error seems to mention the ajax panel control. The rest of the page worked fine until I added the treeview control and the beloow code. Any help would be appreciated. thanks in advance.

Dim Node1, lineNode, stationNode As TreeNode

For Each dr As dssSF.001_NETWORKRow In dsSF.SRT_001_NETWORK
Node1 = New TreeNode
Node1.Text = dr.NETWORK_NM.ToString
Node1.Value = dr.NETWORK_ID.ToString
Node1.SelectAction = TreeNodeSelectAction.Expand
For Each dr2 As dssSF.002_LINERow In dsSF.002_LINE.Select("NETWORK_ID = " & dr.NETWORK_ID, "LINE_NM Asc")
lineNode = New TreeNode
lineNode.Text = dr2.LINE_NM.ToString
lineNode.Value = dr2.LINE_ID.ToString
lineNode.SelectAction = TreeNodeSelectAction.Expand
For Each dr3 As dssSF.003_STATIONRow In dsSF.003_STATION.Select("STATION_ID = " & dr2.STATION_ID)
stationNode = New TreeNode
stationNode.Value = dr3.STATION_ID.ToString
stationNode.Text = dr3.STATION_NM.ToString
lineNode.ChildNodes.Add(stationNode)
Next
Node1.ChildNodes.Add(lineNode)
Next
TreeNetwork.Nodes.Add(Node1)
Next

System.ArgumentOutOfRangeException was unhandled by user code
Message="Specified argument was out of the range of valid values.\r\nParameter name: index"
Source="System.Web"
ParamName="index"
StackTrace:
at System.Web.UI.ControlCollection.get_Item(Int32 index)
at AjaxControlToolkit.TabPanelCollection.get_Item(Int32 index) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\Tabs\TabPanelCollection.cs:line 49
at AjaxControlToolkit.TabContainer.LoadClientState(String clientState) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\Tabs\TabContainer.cs:line 353
at AjaxControlToolkit.ScriptControlBase.LoadPostData(String postDataKey, NameValueCollection postCollection) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:line 313
at AjaxControlToolkit.TabContainer.LoadPostData(String postDataKey, NameValueCollection postCollection) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\Tabs\TabContainer.cs:line 444
at AjaxControlToolkit.ScriptControlBase.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:line 424
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[3554 byte] By [satoriman] at [2007-11-20 11:36:16]
# 1 Re: [2005] Treeview error Specified argument was out of the range of valid values.
Hi

I have found that if I remove the below code that dynamically creates some ajax tab panels that are on the same page, the tree control postback works. Any ideas on what I am doing wrong when creating these tab panels?

For Each dr As dssCategory.table_CATEGORYRow In dscat.table_CATEGORY
t = New TabPanel
t.HeaderText = dr.CATEGORY_NM
Me.TabContainer1.Tabs.Add( t)
Next
satoriman at 2007-11-10 3:08:18 >
# 2 Re: [2005] Treeview error Specified argument was out of the range of valid values.
I have fixed the problem by putting the tab construction code into the page init sub. Although this is one fix I don't know that it is the best solution. Any other ideas?
satoriman at 2007-11-10 3:09:12 >