vs2005 treeview控件 保持展开的状态
我在母版页上放了一个treeview控件,节点内容是读取数据库的,类似CSDN论坛那样的,另外几个页面用了这个母版页,问题是,当我在treeview点 "+" 号展开子节点,然后点击链接跳转页面,这个 "+" 号下的子节点又缩回去了,我想做的是让它保持展开的状态,不知道要怎么实现?代码为: <td style="width: 14%; height: 400px;">
<asp:TreeView ID="tvwauthors" OnTreeNodePopulate="Node_Populate" EnableClientScript="false" runat="server" BackColor="AliceBlue" ImageSet="Contacts" Height="383px" Width="165px" NodeIndent="10">
<ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
<HoverNodeStyle Font-Underline="False" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px"
VerticalPadding="0px" />
<Nodes>
<asp:TreeNode Text="外派人员管理系统" PopulateOnDemand="True" Value="0" Selected="True"/>
</Nodes>
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
</td>
cs
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void Node_Populate(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
switch (e.Node.Depth)
{
case 0:
FillAuthors(e.Node);
break;
case 1:
FillTitlesForAuthors(e.Node);
break;
}
}
}
/// <summary>
/// 生成父节点
/// </summary>
/// <param name="node"></param>
void FillAuthors(TreeNode node)
{
dao = new Hros_Dao();
try
{
OracleConnection connection = dao.OpenCnn();
OracleCommand command = new OracleCommand("select a1.zyid,a2.zy_name from a11_qxfpb a1, a12_zyb a2 where a1.isflag='1' and a2.isflag='1' and roleid=(select roleid from a09_user where userid ='" + employeeID + "') and a1.zyid=a2.pk_zyid", connection);
OracleDataAdapter adapter = new OracleDataAdapter(command);
authors = new DataSet();
adapter.Fill(authors);
}
catch
{
}
if (authors.Tables.Count > 0)
{
foreach (DataRow row in authors.Tables[0].Rows)
{
TreeNode newNode = new
TreeNode(row["ZY_NAME"].ToString(), row["ZYID"].ToString());
newNode.PopulateOnDemand = true;
newNode.SelectAction = TreeNodeSelectAction.Select;
newNode.Expanded = false;
node.ChildNodes.Add(newNode);
}
}
}
/// <summary>
/// 生成子节点
/// </summary>
/// <param name="node"></param>
void FillTitlesForAuthors(TreeNode node)
{
dao = new Hros_Dao();
string authorID = node.Value;
try
{
OracleConnection connection = dao.OpenCnn();
OracleCommand command = new OracleCommand("select * from a14_zyxb where isflag='1'and fk_zyzbid='" + authorID.ToString() + "'", connection);
OracleDataAdapter adapter = new OracleDataAdapter(command);
titlesForAuthors = new DataSet();
adapter.Fill(titlesForAuthors);
}
catch
{
}
if (titlesForAuthors.Tables.Count > 0)
{
foreach (DataRow row in titlesForAuthors.Tables[0].Rows)
{
TreeNode newNode = new TreeNode(row["zyxbname"].ToString(), row["zyxbname"].ToString());
newNode.PopulateOnDemand = true;
newNode.NavigateUrl = row["zyurl"].ToString();
newNode.SelectAction = TreeNodeSelectAction.Select;
newNode.Expanded = false;
node.ChildNodes.Add(newNode);
}
}
}
--------------------编程问答-------------------- 请教各位高人帮忙解决
非常感谢
先顶一下 --------------------编程问答-------------------- newNode.Expanded = true; --------------------编程问答-------------------- newNode.Expanded = true;
--------------------编程问答-------------------- newNode.Expanded = true; --------------------编程问答-------------------- 该回复被版主删除 --------------------编程问答-------------------- newNode.Expanded = true;
初始化是展开呀
这样就每次展开了呀
我们要的效果是初始化是收缩 点击展开后能保存状态呀 --------------------编程问答-------------------- 用cookie --------------------编程问答-------------------- newNode.Expanded = true; --------------------编程问答-------------------- 记录状态判断 --------------------编程问答-------------------- 各位大侠能不能给点代码提示呀 --------------------编程问答-------------------- 用cookie
记录状态判断
怎么用呀
--------------------编程问答-------------------- 本人刚从java转来搞net 希望各位达人多多指教
给点示例代码
定会送分
给出直接游泳代码的朋友100分相送
就还这么多分漏
只要顶的就给分 --------------------编程问答-------------------- 遇到同样问题,等待高手 --------------------编程问答-------------------- Expanded
补充:.NET技术 , ASP.NET