asp.net动态生成TreeView
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class left : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetTreeView();
}
private void GetTreeView()
{
try
{
string connectionstring = "Server=(local);uid=sa;pwd=123456;database=web";//连接SQL数据库
SqlConnection conn = new SqlConnection(connectionstring);
string sql = "select * from menu where menu_level=1 and parent_id =0";//查询一级节点
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds1 = new DataSet();
adapter.Fill(ds1, "temp");
DataTable table1 = ds1.Tables["temp"];//把读取的数据放入DATATABLE中
TreeView1.Nodes.Clear();//建立根节点,遍历。
foreach (DataRow dr1 in table1.Rows)
{
TreeNode root = new TreeNode();
&
相关文档:
前台 aspx 文件:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="List.aspx.cs" Inherits="List" %>
<!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" >
<he ......
1.<%=...%>与<%#... %>的区别:
答:<%=...%>是在程序执行时调用,<%#... %>是在DataBind()方法之后被调用
2.控件接收哪些类型数据?
答:接收Bind的控件,一般有DropDownList,DataList,DataGrid,ListBox这些集合性质 ......
if(MyFile.PostedFile.ContentType != "image/gif"
&& MyFile.PostedFile.ContentType != "image/jpg"
&& MyFile.PostedFile.ContentType != "image/pjpeg"
&& &n ......
//部署桌面快捷方式*******************#region//部署桌面快捷方式*******************
StreamWriter sw2=System.IO.File.CreateText(Context.Parameters["des"].ToString()+"WebSetupTest.url");
stateSaver.Add("DeskQuick",Context.Parameters["des"].ToString() ......
http://ayic1.blog.163.com/blog/static/27343030200965103528805/
静态变量
当我们编写一个类时,其实就是在描述其对象的属性和行为,而并没有产生实质上的对象,只有通过new关键字才会产生出对象,这时系统才会分配内存空间给对象,其方法才可以供外部调用。
& ......