| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 364 人关注过本帖
标题:动态生成静态的html的table(调用数据库直接生成table)
只看楼主 加入收藏
zhouljsh
Rank: 1
等 级:新手上路
帖 子:21
专家分:5
注 册:2010-8-30
结帖率:50%
收藏
 问题点数:0 回复次数:0 
动态生成静态的html的table(调用数据库直接生成table)
/// <summary>
    /// 动态生成静态的html的table(调用数据库直接生成table)
    /// </summary>
    /// <param name="proc"></param>
    /// <param name="para"></param>
    /// <param name="pl"></param>
    public void ReadDtToHtmlTabel(string proc, SqlParameter[] para,Panel pl)
    {
      
        SQLHelper sqlhelper = new SQLHelper();
        DataTable dt = new DataTable();
        sqlhelper.RunProc(proc, para, ref dt);
        string syh = @"""";//双引号
        string headStyle = "class=" + syh + "tabel_Hearder_Back" + syh;
        string rowStyle = "class=" + syh + "tabel_Row_Back" + syh;
        string onclicStyle = " ondblclick=" + syh + "this.style.color='#ff00ff';this.style.font-Size=22px" + syh;
        string onmouseroverStyle = " onmouseover=" + syh + "this.style.color='#ff00ff';this.style.font-Size=22px" + syh;
        string onmouseOunt=" onmouseout= " + syh + "style.backgroundColor='#ffffff'"+syh ;
        string tdStyle = onclicStyle + onmouseOunt + onmouseroverStyle;
        string tableA = "<table>";
        string tableB = "</table>";
        string trA = "<tr "+rowStyle+">";
        string trB = "</tr>";
        string tdA = "<td "+tdStyle +">";
        string tdB = "</td>";

        pl.Controls.Add(new LiteralControl(tableA));
        pl.Controls.Add(new LiteralControl("<tr "+headStyle+">"));
        for (int n = 1; n < dt.Columns.Count; n++)//读出表头
        {
            pl.Controls.Add(new LiteralControl(tdA));
            pl.Controls.Add(new LiteralControl(dt.Columns[n].ColumnName));
            pl.Controls.Add(new LiteralControl(tdB));
        }
        pl.Controls.Add(new LiteralControl(trB));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            pl.Controls.Add(new LiteralControl(trA));
            for (int n = 1; n < dt.Columns.Count; n++)
            {              
               pl.Controls.Add(new LiteralControl(tdA));
               pl.Controls.Add(new LiteralControl(dt.Rows[i][n].ToString()));
               pl.Controls.Add(new LiteralControl(tdB));
            }
            pl.Controls.Add(new LiteralControl(trB));
        }

        pl.Controls.Add(new LiteralControl(tableB));

    }
这里面的事件
string onclicStyle = " ondblclick=" + syh + "this.style.color='#ff00ff';this.style.font-Size=22px" + syh;
        string onmouseroverStyle = " onmouseover=" + syh + "this.style.color='#ff00ff';this.style.font-Size=22px" + syh;
        string onmouseOunt=" onmouseout= " + syh + "style.backgroundColor='#ffffff'"+syh ;
只有ondblclick 起作用,另两个不起作用,就是鼠标在上面的时候并不改变颜色,有谁知道为什么?


[ 本帖最后由 zhouljsh 于 2011-6-24 22:50 编辑 ]
2011-06-24 22:47
快速回复:动态生成静态的html的table(调用数据库直接生成table)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012436 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved