动态生成静态的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 编辑 ]