doubt on creating treeview

6 views
Skip to first unread message

viji

unread,
Oct 21, 2005, 4:09:54 AM10/21/05
to dotnetindia
hi friends,
i created treeview web
control(microsoft.web.ui.webcontrols) .
in my html code it came like this:

<iewc:treeview id="TreeView1" runat="server">
</iewc:treeview>

for this how to add nodes and all.

if anyonr knows pls tell me...



__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

ST Sreetharan

unread,
Oct 21, 2005, 4:30:42 AM10/21/05
to Techdot...@googlegroups.com
Hi Viji
 
You can add the nodes in design mode as well as runtime, see the following at design time
   <iewc:TreeView id="TreeView1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 16px" runat="server">
    <iewc:TreeNode Text="1">
     <iewc:TreeNode Text="1"></iewc:TreeNode>
     <iewc:TreeNode Text="2"></iewc:TreeNode>
     <iewc:TreeNode Text="3"></iewc:TreeNode>
    </iewc:TreeNode>
    <iewc:TreeNode Text="2">
     <iewc:TreeNode Text="1"></iewc:TreeNode>
     <iewc:TreeNode Text="2"></iewc:TreeNode>
     <iewc:TreeNode Text="3"></iewc:TreeNode>
    </iewc:TreeNode>
    <iewc:TreeNode Text="3">
     <iewc:TreeNode Text="1"></iewc:TreeNode>
     <iewc:TreeNode Text="2"></iewc:TreeNode>
     <iewc:TreeNode Text="3"></iewc:TreeNode>
    </iewc:TreeNode>
   </iewc:TreeView>
 
You can do this through code also, see the code
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   TreeNode first,second=null;
   for(int i=1;i<4;i++)
   {
    first=new TreeNode();
    first.Text=i.ToString();
    for(int j=1;j<4;j++)
    {
     second=new TreeNode();
     second.Text=j.ToString();
     second.NavigateURL="link for the page u want to show while clicking this";
   first.Nodes.Add(second);
    }
    TreeView1.Nodes.Add(first);
   }
  }
 
Instead you can bind the data from database also.
 
Cheers
Sreetharan S.T

viji

unread,
Oct 21, 2005, 5:46:28 AM10/21/05
to Techdot...@googlegroups.com
thank u sir...
i got it.

viji

unread,
Oct 21, 2005, 8:41:44 AM10/21/05
to Techdot...@googlegroups.com

hi sir,
in this code cssclass is not applying to text..

how to alter the text(like font-name,size etc...).

<iewc:treeview id="TreeView1" runat="server"
cssclass=".TreeView">
<iewc:TreeNode Text="Reports"
ImageUrl="Controls\treeview\images\plusik.gif">
<iewc:TreeNode Text="Rooms Information"
NavigateUrl="javascript:goToLink(3);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="View Bill"
NavigateUrl="javascript:goToLink(6);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Room wise Revenue"
NavigateUrl="javascript:goToLink(7);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Media Information"
NavigateUrl="javascript:goToLink(8);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Movie Availability"
NavigateUrl="javascript:goSupLink('NS1', 4)"
ImageUrl="Controls\treeview\images\minus.gif" />
</iewc:TreeNode>
</iewc:treeview>

.TreeView
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:0.8em;
font-weight:Normal;
color:navy;
}
--- ST Sreetharan <sts...@gmail.com> wrote:

BabuLives

unread,
Oct 21, 2005, 8:52:56 AM10/21/05
to .NetIndia
Check u have given this line..

<LINK href="ie.css" type="text/css" rel="stylesheet">

Take "." ie cssclass="TreeView">


Regards,
Satheesh

viji

unread,
Oct 21, 2005, 9:06:50 AM10/21/05
to Techdot...@googlegroups.com
hi satheesh,
this is my .ascx file...
where i have to add this link
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="Neos_Navigater.ascx.cs"
Inherits="NeosAdmin.Controls.Neos_Navigater"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<%@ Register TagPrefix="iewc"
Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<table style="BORDER-RIGHT: black 1px solid;
BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px
solid; BORDER-BOTTOM: black 1px solid"
width="142" border="0">
<tr>
<td class="prim">
<%if (strAccess == "NeosSupport") {%>
<link href="NeosAdmin.css" type="text/css"
rel="stylesheet">
<iewc:treeview id="TreeView1" runat="server"
cssclass="TreeView">
<iewc:TreeNode Text="Reports"
ImageUrl="Controls\treeview\images\plusik.gif">
<iewc:TreeNode Text="Rooms Information"
NavigateUrl="javascript:goToLink(3);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="View Bill"
NavigateUrl="javascript:goToLink(6);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Room wise Revenue"
NavigateUrl="javascript:goToLink(7);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Media Information"
NavigateUrl="javascript:goToLink(8);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Movie Availability"
NavigateUrl="javascript:goSupLink('NS1', 4)"
ImageUrl="Controls\treeview\images\minus.gif" />
</iewc:TreeNode>
<iewc:TreeNode Text="Messaging"
ImageUrl="Controls\treeview\images\plusik.gif">
<iewc:TreeNode Text="Guest Message"
NavigateUrl="javascript:goToLink(12);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="View RoomSet"
NavigateUrl="javascript:goToLink(14);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Hotel Message"
NavigateUrl="javascript:goToLink(15);"
ImageUrl="Controls\treeview\images\minus.gif" />
</iewc:TreeNode>
<iewc:TreeNode Text="Update Tv Config"
ImageUrl="Controls\treeview\images\plusik.gif">
<iewc:TreeNode Text="Update Room TV Mode"
NavigateUrl="javascript:goToLink(11);"
ImageUrl="Controls\treeview\images\minus.gif" />
<iewc:TreeNode Text="Update TV Station Type"
NavigateUrl="javascript:goToLink(13);"
ImageUrl="Controls\treeview\images\minus.gif" />
</iewc:TreeNode>
</iewc:treeview>
<!--<A class="prim"
href="javascript:goToLink(3)">Rooms
Information</A><br>
<A class="prim" href="javascript:goToLink(6)">View
Bill</A><br>
<A class="prim" href="javascript:goToLink(7)">Room
wise Revenue</A><br>
<A class="prim" href="javascript:goToLink(8)">Media
Information</A><br>
<A class="prim"
href="javascript:goToLink(11)">Update Room TV
Mode</A><br>
<A class="prim"
href="javascript:goToLink(12)">Guest Message</A><br>
<A class="prim"
href="javascript:goToLink(13)">Update TV Station
Type</A><br>
<A class="prim" href="javascript:goToLink(14)">View
RoomSet</A><br>
<A class="prim"
href="javascript:goToLink(15)">Hotel
Message</A><br>--><A class="prim"
href="javascript:goToLink(16)">Config
Image set</A><br>
<A class="prim"
href="javascript:goToLink(17)">Reboot on
Checkout</A><br>
<A class="prim"
href="javascript:goToLink(18)">Ghost tool
config</A><br>
<!--<A class="prim"
href="javascript:goSupLink('NS1', 4)">Movie
Availability</A><br> -->
<!-- <a href="javascript:goSupLink('NS2', 5)"
class="prim">Checksum Info</a><br> -->
<%} else {%>
<%if (strAccess.IndexOf("checkin") >= 0) {%>
<A class="prim" href="javascript:goToLink(0)">Check
In</A><br>
<%} if (strAccess.IndexOf("checkout") > 0) {%>
<A class="prim" href="javascript:goToLink(1)">Check
Out</A><br>
<%} if (strAccess.IndexOf("roomchange") > 0) {%>
<A class="prim" href="javascript:goToLink(5)">Room
Move</A><br>
<%} if (strAccess.IndexOf("guestprofile") > 0) {%>
<A class="prim" href="javascript:goToLink(2)">Room
preference</A><br>
<%} if (strAccess.IndexOf("guestprofile") > 0) {%>
<A class="prim" href="javascript:goToLink(3)">Rooms
Information</A><br>
<%} if (strAccess.IndexOf("guestbill") > 0) {%>
<A class="prim" href="javascript:goToLink(6)">View
Bill</A><br>
<%} if (strAccess.IndexOf("guestbill") > 0) {%>
<A class="prim" href="javascript:goToLink(7)">Room
wise Revenue</A><br>
<%} if (strAccess.IndexOf("guestbill") > 0) {%>
<A class="prim" href="javascript:goToLink(8)">Media
Information</A><br>
<%} if (strAccess.IndexOf("frequencies") > 0) {%>
<A class="prim"
href="javascript:goToLink(10)">TV/FM Frequency</A><br>
<%} if (strAccess.IndexOf("synchroniseneosrooms") >
0) {%>
<A class="prim"
href="javascript:goToLink(4)">Synchronise
Rooms</A><br>
<%} if (strAccess.IndexOf("agent") > 0) {%>
<A class="prim" href="javascript:goToLink(9)">User
Management</A><br>
<%}%>
<%}%>
<A class="prim"
href="javascript:goToLink(99)"><b>Sign Out</b></A>
</td>
</tr>
</table>

ST Sreetharan

unread,
Oct 21, 2005, 9:30:01 AM10/21/05
to Techdot...@googlegroups.com
Hi Satheesh
     simply giving link to the css file and giving the name of the css class to the control is not at all working with Treeview
 
Sreetharan S.T

viji

unread,
Oct 21, 2005, 9:46:35 AM10/21/05
to Techdot...@googlegroups.com
hi sir,
its not working...


--- ST Sreetharan <sts...@gmail.com> wrote:

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

BabuLives

unread,
Oct 22, 2005, 2:00:55 AM10/22/05
to .NetIndia
hai sree...

then how do we achieve this?


Regards,
Satheesh

viji

unread,
Oct 24, 2005, 3:34:56 AM10/24/05
to Techdot...@googlegroups.com
hai sir

how do we achieve this?

Regards
viji.

ST Sreetharan

unread,
Oct 24, 2005, 4:35:14 AM10/24/05
to Techdot...@googlegroups.com
Hi viji
 I tried this out, but when entering inside also need hard code, I will put some more effort at my leisure to unveil out this problem
see the following code
  private void Page_Load(object sender, System.EventArgs e)
  {
   TreeNode first,second=null;
   TreeView1.CssClass="tree";

   for(int i=1;i<4;i++)
   {
    first=new TreeNode();
     first.DefaultStyle.CssText="tree";

    first.Text=i.ToString();
    for(int j=1;j<4;j++)
    {
     second=new TreeNode();
     second.DefaultStyle.Add("color","green;");//see here i am hardcoding the style
     second.DefaultStyle.Add("font","Verdana;");//see here i am hardcoding the style
     second.Text=j.ToString();
     second.NavigateUrl="link for the page u want to show while clicking this";
     first.Nodes.Add(second);
    }
   TreeView1.Nodes.Add(first);
   }
  }
 
If we are writing this code we can give the effect what we are expecting, but if you wanna change it you have to again re code it. so this will not be the right way. I will try more while I am free,
 
Regards
Sreetharan S.T

viji

unread,
Oct 24, 2005, 10:11:40 AM10/24/05
to Techdot...@googlegroups.com
hi i did like this.its work...

<iewc:TreeNode Text="<font face=verdana size=1
color:#666666 line-height:2
text-decoration:none>Reports</font>"ImageUrl="Controls\treeview\images\plusik.gif">

regards & thanks,
viji
Reply all
Reply to author
Forward
0 new messages