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();
&
相关文档:
在web服务器端开发中经常会遇到各种不同形式的path,而且经常记不清楚如何获取到某种特定格式,今天抽了点时间把常用的path获取方法与格式做了一个简单的对照表,以备日后查用。
Request获取的信息
Request.AppRelativeCurrentExecutionFilePath &nb ......
1.Application:用于保存所有用户共用的数据信息。 在Asp.Net中类似的配置数据最好保存在Web.config文件中。如果使用Application对象,一个需要考虑的问题是任何写操作都要在 Application_OnStart事件(global.asax)中完成。尽管使用Application.Lock和 Application.Unlock方法来避免写操作的同步,但是它串行化了Applicat ......
if(MyFile.PostedFile.ContentType != "image/gif"
&& MyFile.PostedFile.ContentType != "image/jpg"
&& MyFile.PostedFile.ContentType != "image/pjpeg"
&& &n ......