标题:动态生成静态的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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-343919-1-1.html




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

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