单击选择treeview结点

sedan1983 2005-07-29 09:33:55
如何单击选择treeview的结点?
TreeNode node = TreeView.GetNodeFromIndex(TreeView.SelectedNodeIndex)
不能实现!
在线等!谢谢!
...全文
220 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
chxuxu 2005-08-09
  • 打赏
  • 举报
回复
yeskele 2005-08-09
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4190/4190991.xml?temp=9.908694E-02
singlepine 2005-08-08
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4196/4196863.xml?temp=.153454
wenl 2005-08-08
  • 打赏
  • 举报
回复
selectedindexchange好像必须是改变所点的节点才发生,不是单击事件。
sedan1983(sedan)会写javascript让点击节点后跳转其他页么?
douguangyao 2005-08-08
  • 打赏
  • 举报
回复
只能把autopostback设定为true,
其他方法我也不知道
sedan1983 2005-08-08
  • 打赏
  • 举报
回复
有没有其它方式,不需要autopostback设定为true。
yeskele 2005-08-08
  • 打赏
  • 举报
回复
是不是抓不到selectedindexchange这个事件?
要把treeview的autopostback设定为true才行。。不过这样页面闪动很大]
sedan1983 2005-08-08
  • 打赏
  • 举报
回复
如何在用户控件里获得选择结点的ID?
sedan1983 2005-08-01
  • 打赏
  • 举报
回复
我自己顶一下!
sedan1983 2005-07-29
  • 打赏
  • 举报
回复
我知道这样可以实现
在Page_Load里添加如下代码:
this.tvProject.Attributes.Add("onclick", "ClickNode()");
在脚本里添加如下函数:
function ClickNode()
{
alert(tvProject.getTreeNode(tvProject.clickedNodeIndex).getAttribute("Text"));
}
还有其他更简单的方式吗?
jhpxf 2005-07-29
  • 打赏
  • 举报
回复
顶下,分页的效果最好是用JS来实现了
silverseven7 2005-07-29
  • 打赏
  • 举报
回复
private void tvDocDir_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
{
this.SetPageView(MainPageStatus.ViewStatusInit);

try
{
TreeNode node = TreeOperationDB.GetNodeId(this.tvDocDir);

int right = this.GetCurrentNodeRight(node.ID);
if( right < 1 )
{
// Users dont have read permission
return;
}
else if( right < 2 )
{
// Only Read
this.dgDocDetail.Columns[5].Visible = false;
this.btnAddDoc.Visible = false;
}
else if( right < 3 )
{
// Update
this.dgDocDetail.Columns[5].Visible = false;
this.btnAddDoc.Visible = true;
}
else
{
this.dgDocDetail.Columns[5].Visible = true;
this.btnAddDoc.Visible = true;
}

this.Session["DocumentList"] = null;
DataTable dtDocDetail = this.GetDocumentList();

if( dtDocDetail.Rows.Count == 0 )
{
this.DivDocDetail.Visible = false;
}
else
{
this.DivDocDetail.Visible = true;
dgDocDetail.DataSource = dtDocDetail;
dgDocDetail.DataBind();
}

this.SetPageView(MainPageStatus.ViewStatusFileList);
}
catch( ApplicationException ex )
{
if( ex.Message == "1060")
{
this.NodeLostManagement( ex.Message );
}
else if( ex.Message == "1062" )
{
// TreeNode Has been Modifiey
this.ShowMessage(this.GetMessage(ex.Message));

// Rebuild Tree
string treePath = this.tvDocDir.SelectedNodeIndex;
this.rebuildTree(treePath);

this.tvDocDir_SelectedIndexChange( new object() , new Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs("0","0") );
}
}
catch( Exception ex )
{
this.Response.Redirect("Error.aspx?errorMsg="+Server.UrlEncode(ex.Message));
}
}

62,039

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧