看看.net 后台数据调用脚本 及 数据集的问题

1、ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script type='text/javascript' language='javascript'>document.getElementById('PageIframe').src='" + this.TreeView1.SelectedNode.Value + "';</script>", false);

参数为false时注意

2、

/// <summary>
        /// 当列表无记录时显示表头
        /// </summary>
        /// <param name="_GridView">列表控件</param>
         public static void ShowHeader(GridView    _GridView)
        {
            DataTable dt = new DataTable();

            //先加入一行空值
            foreach (DataControlField _cell in _GridView.Columns)
            {
                dt.Columns.Add(_cell.FooterText);

            }
            dt.Rows.Add(dt.NewRow());

            //绑定空数据
            //提示所有绑定的列的FooterText值不能为空!
            _GridView.DataSourceID = "";
            _GridView.DataSource = dt;
            _GridView.DataBind();


            //设置提示信息
            int columnCount = dt.Columns.Count;
            _GridView.Rows[0].Cells.Clear();
            _GridView.Rows[0].Cells.Add(new TableCell());
            _GridView.Rows[0].Cells[0].ColumnSpan = columnCount;
            _GridView.Rows[0].Cells[0].Text = "当前没有记录!";
            _GridView.Rows[0].Cells[0].Style.Add("text-align", "center");
           // _GridView.Rows[0].Enabled = false;

        }

        /// <summary>
        /// 当加载数据列表时显示的提示信息
        /// </summary>
        /// <param name="_Page">当前的aspx页</param>
        /// <param name="_DivID">该列表(如GridView)所属的div的ID值</param>
        /// <param name="_MsgStr">要显示的提示信息</param>
        public static void ShowLoadMessage(Page _Page,string _DivID, string _MsgStr)
        {
           
            string innerHtml = "<script type='text/javascript' language='javascript'>document.getElementById('" + _DivID + "').innerText='" + _MsgStr + "'</script>";
            _Page.ClientScript.RegisterStartupScript(_Page.GetType(), "key", innerHtml, false);
            //Response.Write(innerHtml);
        }

 

3、 /// <summary>
        /// 方法:加载指定根目录名称的目录树
        /// </summary>
        /// <param name="Path">目录集所在的xml文件</param>
        /// <param name="_Tree">目录要求绑定的树</param>
        /// <param name="_RootName">指定的根目录名称</param>
        public void LoadTree(string Path, TreeView _Tree, string _RootName)
        {

            TreeCatagoryManage treeCatMng = new TreeCatagoryManage();
            //treeCatMng.Load(Server.MapPath("../../XMLData/XMLTree.xml"));

            _Tree.Nodes.Clear();

            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(Path);

            //得到顶层节点列表
            XmlNodeList topM = xmldoc.DocumentElement.ChildNodes;
            foreach (XmlNode element in topM)
            {
                if (element.Attributes["ID"].Value.Trim() == _RootName.Trim())
                {
                    XmlNodeList _Nodes = element.ChildNodes;
                    foreach (XmlNode _Node in _Nodes)
                    {
                        //加载一级节点
                        TreeNode node = new TreeNode();
                        node.Text = _Node.Attributes["text"].Value;
                        //网页地址
                        node.Value = _Node.Attributes["value"].Value;
                        _Tree.Nodes.Add(node);


                        //得到该节点的子节点
                        XmlNodeList ChildNodelist = _Node.ChildNodes;

                        //加载二级节点
                        if (ChildNodelist.Count > 0)
                        {
                            TreeNode Childnode;


                            foreach (XmlElement el in ChildNodelist)//读元素值
                            {
                                Childnode = new TreeNode();
                                Childnode.Text = el.Attributes["text"].Value;
                                Childnode.Value = el.Attributes["value"].Value;
                                node.ChildNodes.Add(Childnode);

                            }

                        }
                    }
                    break;
                }

            }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值