4月16
/// <summary>
/// 将datatable数据转化为htmltable显示
/// </summary>
/// <param name="dt">数据表</param>
/// <returns>htmltable代码</returns>
public static string CreateTableHtml(DataTable dt)
{
string tableHtml = string.Empty;
tableHtml += "<table border=\"1\">";
tableHtml += "<tr>";
for (int j = 0; j < dt.Columns.Count; j++)
{
tableHtml += "<td>" + dt.Columns[j].ColumnName + "</td>";
}
tableHtml += "</tr>";
for (int i = 0; i < dt.Rows.Count; i++)
{
tableHtml += "<tr>";
for (int j = 0; j < dt.Columns.Count; j++)
{
tableHtml += "<td>";
tableHtml += string.IsNullOrEmpty(dt.Rows[i][j].ToString()) ? " " : dt.Rows[i][j].ToString();
tableHtml += "</td>";
}
tableHtml += "</tr>";
}
tableHtml += "</table>";
return tableHtml;
}
/// <summary>
/// 将datatable数据转化为htmltable显示,专用于popupwin显示错误信息
/// </summary>
/// <param name="dt">数据表</param>
/// <returns>html代码</returns>
/// ret和retmsg两列不显示;Error单独作为一行显示;
public static string CreateTableHtmlForDisyplayError(DataTable dt)
{
string tableHtml = "";
tableHtml += "<table border=\"1\">";
tableHtml += "<tr>";
for (int j = 2; j < dt.Columns.Count - 1; j++)
{
tableHtml += "<td>" + dt.Columns[j].ColumnName + "</td>";
}
tableHtml += "</tr>";
for (int i = 0; i < dt.Rows.Count; i++)
{
tableHtml += "<tr>";
//前两列为错误提示,不需要显示
for (int j = 2; j < dt.Columns.Count - 1; j++)
{
tableHtml += "<td>";
tableHtml += string.IsNullOrEmpty(dt.Rows[i][j].ToString()) ? " " : dt.Rows[i][j].ToString();
tableHtml += "</td>";
}
tableHtml += "</tr>";
//错误详细信息error单独作为一行显示
tableHtml += "<tr>";
tableHtml += "<td colspan=" + dt.Columns.Count + ">错误详细提示:" + dt.Rows[i][dt.Columns.Count - 1] + "</td>";
tableHtml += "</tr>";
}
tableHtml += "</table>";
return tableHtml;
}
/// 将datatable数据转化为htmltable显示
/// </summary>
/// <param name="dt">数据表</param>
/// <returns>htmltable代码</returns>
public static string CreateTableHtml(DataTable dt)
{
string tableHtml = string.Empty;
tableHtml += "<table border=\"1\">";
tableHtml += "<tr>";
for (int j = 0; j < dt.Columns.Count; j++)
{
tableHtml += "<td>" + dt.Columns[j].ColumnName + "</td>";
}
tableHtml += "</tr>";
for (int i = 0; i < dt.Rows.Count; i++)
{
tableHtml += "<tr>";
for (int j = 0; j < dt.Columns.Count; j++)
{
tableHtml += "<td>";
tableHtml += string.IsNullOrEmpty(dt.Rows[i][j].ToString()) ? " " : dt.Rows[i][j].ToString();
tableHtml += "</td>";
}
tableHtml += "</tr>";
}
tableHtml += "</table>";
return tableHtml;
}
/// <summary>
/// 将datatable数据转化为htmltable显示,专用于popupwin显示错误信息
/// </summary>
/// <param name="dt">数据表</param>
/// <returns>html代码</returns>
/// ret和retmsg两列不显示;Error单独作为一行显示;
public static string CreateTableHtmlForDisyplayError(DataTable dt)
{
string tableHtml = "";
tableHtml += "<table border=\"1\">";
tableHtml += "<tr>";
for (int j = 2; j < dt.Columns.Count - 1; j++)
{
tableHtml += "<td>" + dt.Columns[j].ColumnName + "</td>";
}
tableHtml += "</tr>";
for (int i = 0; i < dt.Rows.Count; i++)
{
tableHtml += "<tr>";
//前两列为错误提示,不需要显示
for (int j = 2; j < dt.Columns.Count - 1; j++)
{
tableHtml += "<td>";
tableHtml += string.IsNullOrEmpty(dt.Rows[i][j].ToString()) ? " " : dt.Rows[i][j].ToString();
tableHtml += "</td>";
}
tableHtml += "</tr>";
//错误详细信息error单独作为一行显示
tableHtml += "<tr>";
tableHtml += "<td colspan=" + dt.Columns.Count + ">错误详细提示:" + dt.Rows[i][dt.Columns.Count - 1] + "</td>";
tableHtml += "</tr>";
}
tableHtml += "</table>";
return tableHtml;
}

WebServices简单例子
《一个男人的梦想》雅尼





