Hi Stephen,
You can try the following code to fire the treeNodeCheckChanged event. this
onlt fires when you change the checkbox and then click on the Item.
Dim tv As New TreeView
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
End Sub
Protected Sub tv_TreeNodeCheckChanged(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.TreeNodeEventArgs)
Response.Write(e.Node.Text)
End Sub
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
tv = e.Row.FindControl("TreeView1")
AddHandler tv.TreeNodeCheckChanged, AddressOf
tv_TreeNodeCheckChanged
End If
End Sub
Regards,
Manish
www.ComponentOne.com
> Hi All,
>
[quoted text clipped - 7 lines]
> Thanks again,
> Stephen
stephen - 16 Apr 2008 16:36 GMT
Hi Manish,
Thanks for the reply but it still did not trigger. If you can take a look at
the sample code and let me know that will be helpful.
<asp:GridView ID="GridView1" runat="server" .....
OnRowDataBound="GridView1_OnRowDataBound"
OnRowCreated="GridView1_OnRowCreated">
<Columns>
<asp:BoundField HeaderText="Order ID" DataField="OrderID" />
<asp:TemplateField>
<ItemTemplate>
<asp:TreeView ID="LinksTreeView" Font-Names="Arial" ForeColor="Blue"
runat="server" ShowCheckBoxes="All"
>
</asp:TreeView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Dynamic Populating the TreeView in Databound....
protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Web.UI.WebControls.TreeView myTreeView =
e.Row.FindControl("LinksTreeView") as System.Web.UI.WebControls.TreeView;
TreeNode myParentNode = new TreeNode();
myParentNode.Text = e.Row.Cells[0].Text;
myParentNode.Value = e.Row.Cells[0].Text;
myParentNode.SelectAction = TreeNodeSelectAction.Expand;
myParentNode.CollapseAll();
myTreeView.Nodes.Add(myParentNode);
PopulateOrderDetails(myParentNode);
}
}
protected void GridView1_OnRowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Web.UI.WebControls.TreeView tv = new
System.Web.UI.WebControls.TreeView();
tv =
(System.Web.UI.WebControls.TreeView)e.Row.FindControl("LinksTreeView");
tv.TreeNodeCheckChanged += new
TreeNodeEventHandler(tv_TreeNodeCheckChanged);
}
}
void tv_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
{
Response.Write(e.Node.Text);
}
I have tried to test the handler in both OnRowCreated and OnRowDataBound but
it does not work either way...
Thanks,
Stephen
> Hi Stephen,
>
[quoted text clipped - 39 lines]
>> Thanks again,
>> Stephen
wisccal@googlemail.com - 17 Apr 2008 05:51 GMT
Hi Stephen,
The TreeView only populates CheckBoxes, but without a corresponding
OnClick event. And there is no such thing as AutoPostBack for
TreeViews. You would have to add OnClick events on your own in
Javascript. For a treatment of the subject and a possible solution ,
visit this thread:
http://forums.asp.net/p/643832/645130.aspx#645130
============
Regards,
Steve
www.stkomp.com
> Hi Manish,
>
[quoted text clipped - 103 lines]
> >> Thanks again,
> >> Stephen
stephen - 22 Apr 2008 23:24 GMT
Hi,
Thanks for all your replies.
Stephen
> Hi Stephen,
>
[quoted text clipped - 127 lines]
>> >> Thanks again,
>> >> Stephen