为什么会出现索引和长度必须引用该字符串内的位置这样的错误
valuePath的值为什么一直是00呢?程序代码:
Public Class WebForm1 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 Call Me.initTree() End If End Sub Sub initTree() Dim valuePath As String Dim i As Integer Dim o As New myData.clsTree Dim dr As SqlClient.SqlDataReader Dim dv As DataView dv = o.getall2ds(" User_id='admin'").Tables(0).DefaultView dr = o.getall2dr("") Dim myNode As TreeNode While dr.Read myNode = New TreeNode myNode.Expanded = False myNode.Value = dr.Item("Typeid").ToString dv.RowFilter = " Typeid='" & myNode.Value & "'" If dv.Count = 0 Then Continue While End If myNode.Text = dr.Item("FullName").ToString 'myNode.ImageUrl = dr.Item("imgUrl").ToString If dr.Item("isGroup") = "0" Then myNode.Target = "WebForm1" myNode.NavigateUrl = "WebForm1.aspx" Else myNode.NavigateUrl = "" End If If dr.Item("Parid") = "0" Then Me.TreeView1.Nodes.Add(myNode) Else valuePath = "" For i = 1 To dr.Item("Parid").ToString.Length / 2 If valuePath = "" Then valuePath = dr.Item("Parid").ToString.Substring(0, i * 2) Else valuePath &= "/" & dr.Item("Parid").ToString.Substring(0, i * 2) End If Next If Not Me.TreeView1.FindNode(valuePath) Is Nothing Then Me.TreeView1.FindNode(valuePath).ChildNodes.Add(myNode) End If End If End While dr.Close() End Sub End Class
[ 本帖最后由 屎宝宝 于 2013-6-3 18:27 编辑 ]