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();
&
相关文档:
1.<%=...%>与<%#... %>的区别:
答:<%=...%>是在程序执行时调用,<%#... %>是在DataBind()方法之后被调用
2.控件接收哪些类型数据?
答:接收Bind的控件,一般有DropDownList,DataList,DataGrid,ListBox这些集合性质 ......
aspx页面代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ENRepeater.aspx.cs" Inherits="ENRepeater" %>
<!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" & ......
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 ......
net 2.0中的新控件ReportViewer可以方便的制作并显示报表,但是它没有直接支持在网页中的打印。我在分析网页HTML源代码的基础上找到了直接打印的诀窍,先做成一个函数,方便直接使用。
1.包含ReportViewer报表的网页的最终形式HTML DOM结构中,报表被放到一个<iframe>中,其id命名方式为: ......