using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using ljcgygl.pub_class;public partial class menu_tree : System.Web.UI.Page { protected string is_yhmc,is_id; public string is_content; // protected Microsoft.Web.UI.WebControls.TreeView TreeView1; User userinfo;
protected void Page_Load(object sender, EventArgs e) { userinfo = eData.GetUserInfo(this); is_yhmc = userinfo.YHMC; is_id=Request.Params["id"]; TreeView1.Nodes.Clear(); ////调用递归函数,完成树形结构的生成 if (userinfo.YHBH.ToLower() == "super") { } else { Total_message(); } if (!IsPostBack) { AddTree("0", TreeView1.Nodes); } } public void AddTree(string as_root, Microsoft.Web.UI.WebControls.TreeNodeCollection pNode) { string ls_sql; string ls_yhbh = userinfo.YHBH; string ls_yhmc = userinfo.YHMC; if (userinfo.YHBH.ToLower() == "super") ls_sql = "Select gnbh, gnmc, fbh, fz, ym, '1' qx From t_s_xtdx " + " Where nvl(fbh,'0')='" + as_root + "' ORDER BY sxh"; else ls_sql = "Select a.gnbh, gnmc, fbh, fz, ym, nvl(qx,'0') qx " + " FROM t_s_xtdx a, t_s_gnfp b Where a.gnbh = b.gnbh and b.jsbh ='" + userinfo.JSBH + "' and nvl(fbh,'0')='" + as_root + "' ORDER BY sxh"; DataTable dt = new DataTable(); if (DBop.SQLSelect(ls_sql, ref dt)) { for (int i = 0; i < dt.Rows.Count; i++) { Microsoft.Web.UI.WebControls.TreeNode tn = new Microsoft.Web.UI.WebControls.TreeNode(); tn.NodeData = dt.Rows[i]["gnbh"].ToString(); tn.Text = dt.Rows[i]["gnmc"].ToString(); if (dt.Rows[i]["ym"] != DBNull.Value) { if (dt.Rows[i]["ym"].ToString().IndexOf("?") > 0) tn.NavigateUrl = dt.Rows[i][4].ToString() + "&edit=" + dt.Rows[i][5].ToString(); else tn.NavigateUrl = dt.Rows[i][4].ToString() + "?edit=" + dt.Rows[i][5].ToString(); } tn.Target = "main"; if (dt.Rows[i]["fz"].ToString() == "0") { if (dt.Rows[i]["qx"].ToString() == "1") tn.ImageUrl = "img/edit.gif"; else tn.ImageUrl = "img/html.gif"; } else { tn.ImageUrl = "img/foot.gif"; tn.ExpandedImageUrl = "img/foot.gif"; } pNode.Add(tn); } for (int j = 0; j < pNode.Count; j++) { string ls_root = pNode[j].NodeData; Microsoft.Web.UI.WebControls.TreeNodeCollection nbic = pNode[j].Nodes; if (ls_root != "") AddTree(ls_root, nbic); } } } private void Total_message() { int li_count; string ls_sql = "select count(*) as count from t_d_tztg_dw a,t_d_tztgfb b " + " where dwbh = '" + userinfo.BMBH + "' and bz = '0' and a.lsh=b.lsh and b.fbsj =sysdate"; DataTable dt = new DataTable(); bool sign = DBop.SQLSelect(ls_sql, ref dt); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; li_count = Convert.ToInt16(dr["count"]); is_content = li_count.ToString(); //is_content = "<a href='http://10.110.1.132/htgl/office/office_news_list.aspx ' target='oldMethod'>" + "您有" +li_count+"条公告未读!"+"</a>"; //is_content = "<a target='oldMethod'> "您有" +li_count+"条公告未读!"</a>"; } }}
AddTree的动作你只在第一次加载页面的时候执行,然后每一次调用Page_Load都会清理树的所有节点,这个不合理吧! if (!IsPostBack) { TreeView1.Nodes.Clear(); AddTree("0", TreeView1.Nodes); } 在加载前清理,不行吗?
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ljcgygl.pub_class;public partial class menu_tree : System.Web.UI.Page
{
protected string is_yhmc,is_id;
public string is_content;
// protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
User userinfo;
protected void Page_Load(object sender, EventArgs e)
{
userinfo = eData.GetUserInfo(this);
is_yhmc = userinfo.YHMC;
is_id=Request.Params["id"];
TreeView1.Nodes.Clear();
////调用递归函数,完成树形结构的生成
if (userinfo.YHBH.ToLower() == "super")
{ }
else
{
Total_message();
}
if (!IsPostBack)
{
AddTree("0", TreeView1.Nodes);
}
}
public void AddTree(string as_root, Microsoft.Web.UI.WebControls.TreeNodeCollection pNode)
{
string ls_sql;
string ls_yhbh = userinfo.YHBH;
string ls_yhmc = userinfo.YHMC;
if (userinfo.YHBH.ToLower() == "super")
ls_sql = "Select gnbh, gnmc, fbh, fz, ym, '1' qx From t_s_xtdx "
+ " Where nvl(fbh,'0')='" + as_root + "' ORDER BY sxh";
else
ls_sql = "Select a.gnbh, gnmc, fbh, fz, ym, nvl(qx,'0') qx "
+ " FROM t_s_xtdx a, t_s_gnfp b Where a.gnbh = b.gnbh and b.jsbh ='" + userinfo.JSBH + "' and nvl(fbh,'0')='" + as_root + "' ORDER BY sxh"; DataTable dt = new DataTable(); if (DBop.SQLSelect(ls_sql, ref dt))
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Microsoft.Web.UI.WebControls.TreeNode tn = new Microsoft.Web.UI.WebControls.TreeNode();
tn.NodeData = dt.Rows[i]["gnbh"].ToString();
tn.Text = dt.Rows[i]["gnmc"].ToString();
if (dt.Rows[i]["ym"] != DBNull.Value)
{
if (dt.Rows[i]["ym"].ToString().IndexOf("?") > 0)
tn.NavigateUrl = dt.Rows[i][4].ToString() + "&edit=" + dt.Rows[i][5].ToString();
else
tn.NavigateUrl = dt.Rows[i][4].ToString() + "?edit=" + dt.Rows[i][5].ToString();
}
tn.Target = "main";
if (dt.Rows[i]["fz"].ToString() == "0")
{
if (dt.Rows[i]["qx"].ToString() == "1")
tn.ImageUrl = "img/edit.gif";
else
tn.ImageUrl = "img/html.gif";
}
else
{
tn.ImageUrl = "img/foot.gif";
tn.ExpandedImageUrl = "img/foot.gif";
}
pNode.Add(tn);
}
for (int j = 0; j < pNode.Count; j++)
{
string ls_root = pNode[j].NodeData;
Microsoft.Web.UI.WebControls.TreeNodeCollection nbic = pNode[j].Nodes;
if (ls_root != "")
AddTree(ls_root, nbic);
}
}
} private void Total_message()
{
int li_count; string ls_sql = "select count(*) as count from t_d_tztg_dw a,t_d_tztgfb b "
+ " where dwbh = '" + userinfo.BMBH + "' and bz = '0' and a.lsh=b.lsh and b.fbsj =sysdate";
DataTable dt = new DataTable();
bool sign = DBop.SQLSelect(ls_sql, ref dt);
if (dt.Rows.Count > 0)
{
DataRow dr = dt.Rows[0];
li_count = Convert.ToInt16(dr["count"]); is_content = li_count.ToString();
//is_content = "<a href='http://10.110.1.132/htgl/office/office_news_list.aspx ' target='oldMethod'>" + "您有" +li_count+"条公告未读!"+"</a>";
//is_content = "<a target='oldMethod'> "您有" +li_count+"条公告未读!"</a>"; } }}
AddTree的动作你只在第一次加载页面的时候执行,然后每一次调用Page_Load都会清理树的所有节点,这个不合理吧!
if (!IsPostBack)
{
TreeView1.Nodes.Clear();
AddTree("0", TreeView1.Nodes);
}
在加载前清理,不行吗?
嘿嘿嘿嘿~~~~~