a) Treeview control and datalist
b) Treeview operations
Program:
b) Treeview operations
Program:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Practical_3c._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1"
runat="server" ImageSet="BulletedList3"
ShowExpandCollapse="False">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD"
/> <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD"
HorizontalPadding="0px" VerticalPadding="0px" /> <Nodes>
<asp:TreeNode Text="Bsc. IT" Value="Bsc. IT">
<asp:TreeNode Text="TYIT" Value="TYIT">
<asp:TreeNode Text="Adv. Web" Value="Adv. Web"></asp:TreeNode>
<asp:TreeNode Text="IoT" Value="IoT"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="SYIT" Value="SYIT">
<asp:TreeNode Text="Computer
N/w" Value="Computer
N/w"></asp:TreeNode>
<asp:TreeNode Text="Python" Value="Python"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="FYIT" Value="FYIT">
<asp:TreeNode Text="Imperative
Programming" Value="Imperative Programming">
</asp:TreeNode>
<asp:TreeNode Text="Operating
Sys." Value="Operating
Sys."></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<br />
<asp:DataList ID="DataList1"
runat="server" BackColor="#CC66FF" CellPadding="4"
Font-Bold="True" Font-Italic="True" Font-Names="David" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" ForeColor="#333333">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"
/> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/> <ItemTemplate>
<table class = "table" border="1">
<tr>
<td>Roll Num : <%# Eval("sid") %><br />
Name : <%# Eval("sname")
%><br />
Class : <%# Eval("sclass")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Practical_3c
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
{
BindData();
}
}
protected void BindData()
{
DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("studentdetail.xml")); if (ds != null && ds.HasChanges()) {
DataList1.DataSource = ds;
DataList1.DataBind();
}
else
{
DataList1.DataBind();
}
}
}
}
Studentdetail.xml
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1</sid>
<sname>John</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>2</sid>
<sname>Joy</sname>
<sclass>SYCS</sclass>
</student>
<student>
<sid>3</sid>
<sname>Angel</sname>
<sclass>SYIT</sclass>
</student>
<student>
<sid>4</sid>
<sname>Tony</sname>
<sclass>TYCS</sclass>
</student>
</studentdetail>
Comments
Post a Comment