悬赏园豆:200
[已解决问题]
解决于 2007-12-03 11:52
<P>用TreeView动态从数据库里面读取数据,有时会出现'TreeView1_data'未定义的错误, <BR><BR>我在网络上查了一下,主要是由于该控件没有加载完毕所引起的, <BR><BR>我想请问有什么好的解决办法? <BR><BR>或是如何判断这个控件是否加载完毕,代码应该怎么写? <BR><BR>谢谢大家! </P>
<P>我的代码如下:<BR>//开始动态绑定导航栏<BR>DataView DV3 = Socut.Data.ExecuteDataSet("select title,id from vod_catalog order by number desc").Tables[0].DefaultView;<BR>foreach (DataRowView datav in DV3)<BR>{<BR>TreeNode tn = new TreeNode();<BR>tn.Text = datav["title"].ToString();<BR>tn.Value = datav["id"].ToString();<BR>tn.Expanded = false;</P>
<P>tn.SelectAction = TreeNodeSelectAction.Expand;</P>
<P>TreeView1.Nodes.Add(tn);</P>
<P>AddChildNodes(tn);<BR>}</P>
<P>public void AddChildNodes(TreeNode tnChild)<BR>{<BR>int bid = Convert.ToInt32(tnChild.Value);<BR>DataView DV = Socut.Data.ExecuteDataSet("select title,id from vod where catalog_id=" + bid + "").Tables[0].DefaultView;<BR>foreach (DataRowView datav in DV)<BR>{<BR>TreeNode tn2 = new TreeNode();<BR>tn2.Text = datav["title"].ToString();<BR>tn2.Value = datav["id"].ToString();<BR>tn2.NavigateUrl = "vod.aspx?id=" + datav["id"].ToString();<BR>tnChild.ChildNodes.Add(tn2);<BR>}<BR>}</P>
<P mce_keep="true"> </P>