Treeview, event and databinding

Discussion in 'ASP .Net' started by samarobrive, Nov 26, 2009.

  1. samarobrive

    samarobrive Guest

    For a CMS, I use the treeview control with CSS friendly adapter binded with
    the sitemap :

    <asp:TreeView DataSourceID="SiteMapDataSource1" ID="EntertainmentTreeView"
    runat="server" OnSelectedNodeChanged="OnClick"
    OnAdaptedSelectedNodeChanged="OnClick" >
    <DataBindings>
    <asp:TreeNodeBinding DataMember="SiteMapNode" TextField="Title"
    ValueField="url" />
    </DataBindings>
    </asp:TreeView>

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

    But when I click on a node, the treeview does not respond, doesn't send
    event. If I replace the ValueField "url" by for example "title", the event is
    ok.

    How can I force the treeview to send Event with ValueField="url" ?

    You can see a sample at www.almageste.info/preuve2.zip.

    Thanks for your help !

    ________
    The page code is :

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    public void OnClick(Object sender, EventArgs e)
    {
    MessageLabel.Text = "You selected " +
    EntertainmentTreeView.SelectedNode.Text + ".";
    }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:TreeView DataSourceID="SiteMapDataSource1" ID="EntertainmentTreeView"
    runat="server" OnSelectedNodeChanged="OnClick"
    OnAdaptedSelectedNodeChanged="OnClick">
    <DataBindings>
    <asp:TreeNodeBinding DataMember="SiteMapNode" TextField="Title"
    NavigateUrlField="url" SelectAction="Select" />
    </DataBindings>
    </asp:TreeView>
    <asp:Label ID="MessageLabel" runat="server" />
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
    </form>
    </body>
    </html>

    And the Sitemapdatasource is:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title="" description="">
    <siteMapNode url="url1.aspx" title="url title 1" description="description 1"
    />
    <siteMapNode url="url2.aspx" title="url title 2" description="description 2"
    />
    </siteMapNode>
    </siteMap>
     
    samarobrive, Nov 26, 2009
    #1
    1. Advertising

  2. =?Utf-8?B?c2FtYXJvYnJpdmU=?= <>
    wrote in news::

    > For a CMS, I use the treeview control with CSS friendly adapter binded
    > with the sitemap :
    >
    > <asp:TreeView DataSourceID="SiteMapDataSource1"
    > ID="EntertainmentTreeView"
    > runat="server" OnSelectedNodeChanged="OnClick"
    > OnAdaptedSelectedNodeChanged="OnClick" >
    > <DataBindings>
    > <asp:TreeNodeBinding DataMember="SiteMapNode" TextField="Title"
    > ValueField="url" />
    > </DataBindings>
    > </asp:TreeView>
    >
    > <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
    >
    > But when I click on a node, the treeview does not respond, doesn't
    > send event. If I replace the ValueField "url" by for example "title",
    > the event is ok.


    Are you trying to use the Treeview as a menu? If so, you don't have to be
    sneaky. Just set the NavigateUrl property to the URL.

    Peace and Grace,

    --
    Gregory A. Beamer
    Microsoft MVP (Visual C# Architecture)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    **********************************************
    | Think outside the box! |
    **********************************************
     
    Gregory A. Beamer (MVP), Nov 26, 2009
    #2
    1. Advertising

  3. samarobrive

    samarobrive Guest

    I don't want to use NavigateURL and I don't use the Treeview as a menu. I
    want just click on a leaf and send an event to the onclick method. This
    program works fine without CSS Friendly but not with.

    I have tried many forums but you are my last chance !

    Thanks for your help !

    "Gregory A. Beamer (MVP)" wrote:

    > =?Utf-8?B?c2FtYXJvYnJpdmU=?= <>
    > wrote in news::
    >
    > > For a CMS, I use the treeview control with CSS friendly adapter binded
    > > with the sitemap :
    > >
    > > <asp:TreeView DataSourceID="SiteMapDataSource1"
    > > ID="EntertainmentTreeView"
    > > runat="server" OnSelectedNodeChanged="OnClick"
    > > OnAdaptedSelectedNodeChanged="OnClick" >
    > > <DataBindings>
    > > <asp:TreeNodeBinding DataMember="SiteMapNode" TextField="Title"
    > > ValueField="url" />
    > > </DataBindings>
    > > </asp:TreeView>
    > >
    > > <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
    > >
    > > But when I click on a node, the treeview does not respond, doesn't
    > > send event. If I replace the ValueField "url" by for example "title",
    > > the event is ok.

    >
    > Are you trying to use the Treeview as a menu? If so, you don't have to be
    > sneaky. Just set the NavigateUrl property to the URL.
    >
    > Peace and Grace,
    >
    > --
    > Gregory A. Beamer
    > Microsoft MVP (Visual C# Architecture)
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > **********************************************
    > | Think outside the box! |
    > **********************************************
    > .
    >
     
    samarobrive, Nov 27, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. volts
    Replies:
    0
    Views:
    535
    volts
    Apr 7, 2004
  2. Alex D.

    Databinding Treeview to XML

    Alex D., Jun 5, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    331
    Alex D.
    Jun 5, 2006
  3. Alex D.

    Databinding Treeview to XML??

    Alex D., Jun 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    428
    Alex D.
    Jun 6, 2006
  4. jobs
    Replies:
    0
    Views:
    1,767
  5. Earl Teigrob
    Replies:
    1
    Views:
    444
    Shravan
    Mar 1, 2004
Loading...

Share This Page