Introduction
We can easy to create tree view at run time using asp.net1.1 and sql server2000
Using the code
DataView dv = ds.Tables[0].DefaultView;
StringBuilder s = new StringBuilder();
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");
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");
TableRow tRow = new TableRow();
TableCell tCell = new TableCell();
tCell.Text = s.ToString();
tRow.Cells.Add(tCell);
Table1.Rows.Add(tRow);