TreeView In GridView - OnTreeNodeCheckChanged event problem
TreeView In GridView - OnTreeNodeCheckChanged event problem
am 16.04.2008 00:33:57 von Stephen Noronha
Hi All,
I have a TreeView with CheckBoxes in one of the cells of a GridView and
OnTreeNodeCheckChanged event it does nothing (basically does not postback)
but if I have a button on the page then the OnTreeNodeCheckChanged get
triggered on PostBack. Can some please help me understand why? and how to
get it to postback from GridView itself? any sample articles would be
helpful....
Thanks again,
Stephen
RE: TreeView In GridView - OnTreeNodeCheckChanged event problem
am 16.04.2008 10:53:01 von Manish
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
"stephen" wrote:
>
> Hi All,
>
> I have a TreeView with CheckBoxes in one of the cells of a GridView and
> OnTreeNodeCheckChanged event it does nothing (basically does not postback)
> but if I have a button on the page then the OnTreeNodeCheckChanged get
> triggered on PostBack. Can some please help me understand why? and how to
> get it to postback from GridView itself? any sample articles would be
> helpful....
>
> Thanks again,
> Stephen
>
>
>
Re: TreeView In GridView - OnTreeNodeCheckChanged event problem
am 16.04.2008 17:36:46 von Stephen Noronha
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.
OnRowDataBound="GridView1_OnRowDataBound"
OnRowCreated="GridView1_OnRowCreated">
runat="server" ShowCheckBoxes="All"
>
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("Links TreeView");
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
"Manish" wrote in message
news:FCE98DEC-EC44-4313-916E-2DC324FC8320@microsoft.com...
> 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
>
>
> "stephen" wrote:
>
>>
>> Hi All,
>>
>> I have a TreeView with CheckBoxes in one of the cells of a GridView and
>> OnTreeNodeCheckChanged event it does nothing (basically does not
>> postback)
>> but if I have a button on the page then the OnTreeNodeCheckChanged get
>> triggered on PostBack. Can some please help me understand why? and how to
>> get it to postback from GridView itself? any sample articles would be
>> helpful....
>>
>> Thanks again,
>> Stephen
>>
>>
>>
Re: TreeView In GridView - OnTreeNodeCheckChanged event problem
am 17.04.2008 06:51:16 von wisccal
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
stephen wrote:
> 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.
>
>
> OnRowDataBound="GridView1_OnRowDataBound"
> OnRowCreated="GridView1_OnRowCreated">
>
>
>
>
>
> runat="server" ShowCheckBoxes="All"
> >
>
>
>
>
>
>
> 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("Links TreeView");
> 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
>
>
> "Manish" wrote in message
> news:FCE98DEC-EC44-4313-916E-2DC324FC8320@microsoft.com...
> > 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
> >
> >
> > "stephen" wrote:
> >
> >>
> >> Hi All,
> >>
> >> I have a TreeView with CheckBoxes in one of the cells of a GridView and
> >> OnTreeNodeCheckChanged event it does nothing (basically does not
> >> postback)
> >> but if I have a button on the page then the OnTreeNodeCheckChanged get
> >> triggered on PostBack. Can some please help me understand why? and how to
> >> get it to postback from GridView itself? any sample articles would be
> >> helpful....
> >>
> >> Thanks again,
> >> Stephen
> >>
> >>
> >>
Re: TreeView In GridView - OnTreeNodeCheckChanged event problem
am 23.04.2008 00:24:20 von Stephen Noronha
Hi,
Thanks for all your replies.
Stephen
wrote in message
news:3ea57f76-e77f-4007-bdd2-72edf123f902@k37g2000hsf.google groups.com...
> 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
>
> stephen wrote:
>> 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.
>>
>>
>> OnRowDataBound="GridView1_OnRowDataBound"
>> OnRowCreated="GridView1_OnRowCreated">
>>
>>
>>
>>
>>
>> runat="server" ShowCheckBoxes="All"
>> >
>>
>>
>>
>>
>>
>>
>> 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("Links TreeView");
>> 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
>>
>>
>> "Manish" wrote in message
>> news:FCE98DEC-EC44-4313-916E-2DC324FC8320@microsoft.com...
>> > 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
>> >
>> >
>> > "stephen" wrote:
>> >
>> >>
>> >> Hi All,
>> >>
>> >> I have a TreeView with CheckBoxes in one of the cells of a GridView
>> >> and
>> >> OnTreeNodeCheckChanged event it does nothing (basically does not
>> >> postback)
>> >> but if I have a button on the page then the OnTreeNodeCheckChanged get
>> >> triggered on PostBack. Can some please help me understand why? and how
>> >> to
>> >> get it to postback from GridView itself? any sample articles would be
>> >> helpful....
>> >>
>> >> Thanks again,
>> >> Stephen
>> >>
>> >>
>> >>