Treeview, event and databinding

S

samarobrive

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>
 
G

Gregory A. Beamer (MVP)

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,
 
S

samarobrive

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 !
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top