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;
public partial class SetManage_druclass : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitTreeView(null, 0);
}
}
public void InitTreeView(TreeNode pNode, int parentID)
{
DataSet ds = new DataSet();//ÕâÀïµ÷ÓÃÊý¾Ý¿â»ñÈ¡Êý¾ÝÔ´
TreeNode node;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
node = new TreeNode();
//½ÚµãÃû³Æ
node.Text = ds.Tables[0].Rows[i]["CATEGORY_NAME"].ToString();
//½ÚµãID
int currID = 0;
int.TryParse(ds.Tables[0].Rows[i]["CATEGORY_ID"].ToString(), out currID);
//ÅжÏÊDz»ÊǸù½Úµã
if (pNode == null)
this.TreeView1.Nodes.Add(node);
else
pNode.ChildNodes.Add(node);
//µÝ¹éµ÷ÓÃ
InitTreeView(node, currID);
}
}
}
}
Ò³ÃæЧ¹ûÈçÏÂͼ£º
Ïà¹ØÎĵµ£º
ÔÚ¡¶ASP.NET¿ª·¢£ºÔÚÓû§¿Ø¼þÖÐÌí¼ÓÊôÐÔ¡·ÕâһƪÎÄÕÂÖÐÎÒÃǶ¨ÒåÁËÒ»¸öÓû§µÇ¼µÄÓû§¿Ø¼þUserLogin.ascx Îļþ£¬ÀïÃæ°üº¬ÁËÒ»¸öLinkButton·þÎñÆ÷°´Å¥¿Ø¼þ£¬µ±Óû§µ¥»÷¸Ã°´Å¥Ê±·þÎñÆ÷¶Ë»á×Ô¶¯Éú³ÉÒ»¸ö»Ø·¢À´¼¤·¢Page.Loadʼþ¡£³ýÁË·þÎñÆ÷×Ô¶¯²úÉú»Ø·¢À´¼¤·¢Page.LoadʼþÍ⣬ÎÒÃÇ¿ÉÒÔ¸øLinkButtonÌí¼ÓÒ»¸öËü×Ô¼ºµÄʼþ ......
ʹÓà SqlDataSource ¿Ø¼þÖ»ÐèºÜÉٵĴúÂë»òÎÞÐèÈκδúÂë¼´¿É´ÓÊý¾Ý¿âÖмìË÷Êý¾Ý¡£SqlDataSource ¿Ø¼þ¿ÉÓÃÓÚÈκξßÓйØÁª ADO.NET Ìṩ³ÌÐò£¨ÔÚÅäÖÃÎļþµÄ DbProviderFactories ½ÚÖÐÅäÖ㩵ÄÊý¾Ý¿â£¬°üÀ¨ Microsoft SQL Server¡¢Oracle¡¢ODBC »ò OLE DB Êý¾Ý¿â£¨Èç Microsoft Access£©¡£ÄúÔÚÅäÖÃʱָ¶¨ SqlDataSource ʹÓõ ......
¿ÉÒÔʹÓà SqlDataSource ¿Ø¼þÐÞ¸ÄÊý¾Ý¿âÖеÄÊý¾Ý¡£Ê¹Óøüз½°¸ÖÐµÄ SqlDataSource ¿Ø¼þµÄ×î³£Ó÷½·¨ÊǼìË÷Êý¾Ý²¢Ê¹ÓÃÊý¾Ý°ó¶¨ Web ·þÎñÆ÷¿Ø¼þ£¨Èç GridView¡¢DetailsView »ò FormView ¿Ø¼þ£©ÏÔʾÊý¾Ý¡£¿ÉÒÔÅäÖÃÊý¾Ý°ó¶¨¿Ø¼þºÍ SqlDataSource ÒÔ¸üÐÂÊý¾Ý¡£´ó¶àÊýÊý¾Ý°ó¶¨¿Ø¼þ¶¼ÔÊÐíÄú½«Æä ......
1. ʹÓÃQueryString±äÁ¿
QueryStringÊÇÒ»Öַdz£¼òµ¥µÄ´«Öµ·½Ê½£¬Ëû¿ÉÒÔ½«´«Ë͵ÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖС£Èç¹ûÊÇ´«µÝÒ»¸ö»ò¶à¸ö°²È«ÐÔÒªÇ󲻸߻òÊǽṹ¼òµ¥µÄÊýֵʱ£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£µ«ÊǶÔÓÚ´«µÝÊý×é»ò¶ÔÏóµÄ»°£¬¾Í²»ÄÜÓÃÕâ¸ö·½·¨ÁË¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
a.aspxµÄC#´úÂë
private void Button1_Click(object sen ......