use stack to initial a treeview with the data in a database
来源:互联网 发布:yy网络主播赵哈哈 编辑:程序博客网 时间:2024/04/30 05:19
try
{
if(!Page.IsPostBack)
{
Stack s1 = new Stack();
Stack s2 = new Stack();
Stack s3 = new Stack();
s1.Push("00");
string temp = "";
string strSql = "select rights.right_code from rights,user_right where rights.right_code=user_right.right_code and user_right.user_code='"+Session["UserCode"].ToString()+"' order by rights.right_code desc";
mySQL.strConn="server=localhost;database=LIMS;uid=sa;pwd=sa;";
DataView dv = (DataView)mySQL.ExecuteDataSource(strSql);
for(int i=0;i<dv.Count;i++)
{
while(s1.Count>0)
{
temp = s1.Pop().ToString();
if(temp != dv[i]["RIGHT_CODE"].ToString().Substring(0,temp.Length))
break;
}
s1.Push(temp);
for(int j=dv[i]["RIGHT_CODE"].ToString().Length/2;j>0;j--)
s1.Push(dv[i]["RIGHT_CODE"].ToString().Substring(0,2*j));
}
while(s1.Count>0)
{
s2.Push(s1.Pop());
}
s2.Pop();
//È¡Ê÷ÐÍÊý¾ÝÅÅÁÐs2
strSql = "select right_code,right_name,page_code from rights order by right_code";
dv.Dispose();
dv = (DataView)mySQL.ExecuteDataSource(strSql);
dv.Sort = "right_code";
DataRowView drv;
while(s2.Count>0)
{
temp = s2.Pop().ToString();
Microsoft.Web.UI.WebControls.TreeNode cc = new Microsoft.Web.UI.WebControls.TreeNode();
drv = dv.FindRows(temp)[0];
if(drv["Page_Code"].ToString()=="")
{
cc.Text = drv["right_name"].ToString();
while(s3.Count>0)
{
temp = s1.Pop().ToString();
if(temp.Length>drv["right_code"].ToString().Length)
cc.Nodes.Add((Microsoft.Web.UI.WebControls.TreeNode)s3.Pop());
else
{
s1.Push(temp);
break;
}
}
}
else
{
cc.Text = drv["right_name"].ToString();
cc.NavigateUrl = drv["page_code"].ToString().Substring(0,drv["page_code"].ToString().IndexOf(';'));
//as frame used, using following coding to set target of a hyperlink
// if(cc.Text=="select checkout") // {
// cc.Target="_blank";
// }
// else
// {
cc.Target = "main";
// }
}
s3.Push(cc);
s1.Push(drv["right_code"].ToString());
}
while(s3.Count>0)
this.TreeView1.Nodes.Add((Microsoft.Web.UI.WebControls.TreeNode)s3.Pop());
s1.Clear();
}
}
catch
{return;}
- use stack to initial a treeview with the data in a database
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- a interface to stack that implement use the fixed array.
- Creating a Data dictionary file to use with LogMi
- how to use the mathmatical constant "e" in conjunction with a vector
- 94.You plan to move data from a flat file to a table in your database. You decide to use SQL*Loader
- How to use the pointer of function in a class?
- Use matlab to traverse the files in a folder
- A program use java to connect DataBase
- Use the Stack mehod and a temporary Stack to retrieve entries from the Stack source and add
- How to use a SQL Server database with your PHP web site
- Importing XML Data to a Database
- Posting Data to a Connected Database
- Large Interconnected Data Belongs to a Database
- Large, Interconnected Data Belongs to a Database
- use database 很慢/You can turn off this feature to get a quicker startup with –A
- MSDEGUI - a GUI tool to help developers use the MSDE database
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- ISAPI筛选器及对ASP源文件的保护
- 安装SATA硬盘
- ActiveForm 带参数用法
- delphi多线程程序示例(与.net一样简单)
- 金蝶与Sun签署战略合作协议:共拓Java市场
- use stack to initial a treeview with the data in a database
- 继李开复之后 Google挖角UT斯达康CEO周韶宁
- 今天有点困,脑袋不是很清醒!
- 不要忽略c#中的using和as操作符(转)
- ISAPI筛选器编写
- Apache/PHP/Mysql服务器简单安全防护
- 运用 ADO.NET 对象优化数据查询代码
- 幽城幻剑录完美攻略~~
- 领会类方法