• 动态生成Table内文字换行。


    后台动态生成table,并把td内的文字进行换行。

    前台:

    <body style="100%;height:540px;margin-left:0px;margin-top:0px;overflow:scroll">
    <form id="form1" style="font-size:10pt" runat="server">
    <div >
        <table width="95%"  border="0"  align="center" cellpadding="3" style="table-layout:fixed;" cellspacing="1" bgcolor="#A2C1C8" id="tbContent" runat="server">
            <tr>
                <td colspan="3" style="background-color:#deebef" align="center" >流程开始</td>
            </tr>
        </table>
        
    </div>
    </form>
    </body>

    后台:

      protected void show()
        {
            try
            {
                string eventinfoid = Server.UrlDecode(Request.QueryString["eventinfoid"].ToString());
                DataTable dtFlowOperationState = new DataTable();
                dtFlowOperationState = flowBLL.GetList(" eventid='" + eventinfoid + "' order by newaddtime asc").Tables[0];
                int i = 1;
                foreach (DataRow dr in dtFlowOperationState.Rows)
                {
                    HtmlTableRow row = new HtmlTableRow();
                    HtmlTableCell cell = new HtmlTableCell();
                    cell.Align = "center";
                    cell.BgColor = "#f7f7f7";
                    cell.InnerText = "" + i.ToString() + "";
                   
                    i++;
                    row.Cells.Add(cell);
    
                    cell = new HtmlTableCell();
                    cell.Align = "left";
                    cell.BgColor = "#f7f7f7";
                   
                    string strTemp = "";
                    string UserName = getUserNameByID(dr["dealpeopleid"].ToString());
                    string dealtypeO = dr["dealtype"].ToString();
                    string delatime = dr["dealtime"].ToString();
                    string newaddtime = dr["newaddtime"].ToString();
                    if (!string.IsNullOrEmpty(delatime) && !string.IsNullOrEmpty(newaddtime))
                    {
                        strTemp += UserName + "[<font color='#008200'>" + dealtypeO + "&nbsp;用时:" + getTimeCount(Convert.ToDateTime(delatime), Convert.ToDateTime(newaddtime)) + "</font>]<br />";
                        strTemp += "开始于:" + newaddtime + "<br />";
                        strTemp += "步骤结束于:" + delatime + "<br />";
                    }
                    else
                    {
                        strTemp += UserName + "[<font color='#008200'>" + dealtypeO + "&nbsp;用时:0天0时0分0秒" +"</font>]<br />";
                        strTemp += "开始于:" + newaddtime + "<br />";
                        strTemp += "步骤结束于:正在处理中....<br />";
                    }
                    cell.InnerHtml = strTemp;
                    row.Cells.Add(cell);
    
                    cell = new HtmlTableCell();
                    cell.Align = "left";
                    cell.VAlign = "top";
                    cell.BgColor = "#f7f7f7";
                    cell.Style.Add("word-wrap","break-word");//控制table换行
                    cell.Width = "400";
                    cell.InnerText = "意见:" + dr["dealcontext"].ToString();
                    row.Cells.Add(cell);
                    this.tbContent.Rows.Add(row);
                }
            }
            catch (System.Exception ex)
            {
                //ProcessException("JHLOA_New", "WorkFlow_Flow_PreviewFlowView", "show", ex.Message);
                //Response.Redirect("../../error.aspx?id=3");
            }
        }
        #region 获取时间差
        public string getTimeCount(DateTime onTime, DateTime offTime)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                TimeSpan ts = onTime - offTime;
                if (ts.Days > 0)
                {
                    sb.Append(ts.Days.ToString());
                    sb.Append("");
                }
                sb.Append(ts.Hours.ToString());
                sb.Append("小时");
                sb.Append(ts.Minutes.ToString());
                sb.Append("");
                sb.Append(ts.Seconds.ToString());
                sb.Append("");
            }
            catch (System.Exception ex)
            {
    
            }
            return sb.ToString();
        }
        #endregion

    其中:

    cell.Style.Add("word-wrap","break-word");//控制table换行
    cell.Width = "400";

    控制意见进行换行。

  • 相关阅读:
    laravel获取不到session
    laravel表单提交419错误
    'cross-env' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
    centos 虚拟机出问题 Oh no,something has gone wrong! 解决方法
    fastadmin关闭验证码登录
    php二维数组排序
    不自动显示html表单记住的内容 自动完成等清除记忆
    两个服务器之间使用minio同步文件
    redis获取数据库个数
    html跳转页面
  • 原文地址:https://www.cnblogs.com/smile-wei/p/3361533.html
Copyright © 2020-2023  润新知