Click here to Skip to main content
Licence CPOL
First Posted 24 Jan 2008
Views 8,976
Downloads 56
Bookmarked 9 times

Create Treeview Control at run time using ASP.NET1.1 and Sql Server 2000

By | 24 Jan 2008 | Article
Create Treeview Control at run time and binding data from Sql Server 2000 using ASP.NET1.1

Introduction

We can easy to create tree view at run time using asp.net1.1 and sql server2000

Using the code

            
//------- Load Dataset To DataView------

DataView dv = ds.Tables[0].DefaultView;

//--------------------------------------



<pre>        

//----- Assagin StringBuilder------------

StringBuilder s = new StringBuilder();

//---------------------------------------

//------- Create Parent Node at Run Time-----------

s.Append("<div> <TABLE><TR><TD vAlign=\"middle\" width=\"18\">");

s.Append("<a id=\"treeMain\" href=\"javascript:Toggle('treeMain')\">");

s.Append("<img src='minus.gif' width='16' height='16' hspace='0' vspace='0' border='0'></a>\r");

s.Append("</TD><TD><P>Employees</P></TD></TR>\r");

s.Append("<TR id=\"xtreeMain\"><TD vAlign='top' width='18'></TD><TD vAlign='middle'>\r");



//--------- Create Child node from DataView at Run Time--------------

foreach (DataRowView dataRow in dv)

{

s.Append("<TABLE><TR><TD vAlign='middle' width='18'>");

s.Append("<IMG src='im_next_level.gif'></TD><TD>\r");

string tdName = dataRow.Row.ItemArray[2].ToString();

s.Append(tdName);

s.Append("</TD></TR></TABLE>\r");

} 



s.Append("</TD></TR></TABLE></div>\r");

//------------------ Add StringBuilder To Main Table

TableRow tRow = new TableRow();

TableCell tCell = new TableCell();

tCell.Text = s.ToString();

tRow.Cells.Add(tCell); 

Table1.Rows.Add(tRow); 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

AMVenis

Software Developer

India India

Member

A.M.Venis
MCAD (Microsoft Certified Application Developer) Certified in .Net Framework with C#

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 24 Jan 2008
Article Copyright 2008 by AMVenis
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid