在Repeater中绑定Treeview

时间:2011-06-09 07:47:27

标签: c# asp.net treeview repeater

我想将树视图绑定在转发器内部,如下图所示:

enter image description here

请告诉我怎样才能做到这一点。

1 个答案:

答案 0 :(得分:0)

试试这个

protected void myRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
    {
        TreeView MyTree = (TreeView)e.Item.FindControl("MyTreeID");
        MyTree.DataSource = MyDataSoure;
        MyTree.DataBind();
    }
}