public string CreateTable()
        {

           
            StringBuilder sb = new StringBuilder("");
            int row = 1;//行数
           
            if (true )//是否有数据
            {
                int nRowCount = 10;//所有条数

                row = (int)Math.Ceiling(nRowCount / 5.0);//5.0表示每行有多少条数据
                int colNum = 5;//列数

                for (int m = 0; m < row; m++)
                {
                    //if (m % 2 == 0)    //偶数行
                    //{
                    //    sb.Append("<tr class=\"one_tr\">"); //偶数行样式
                    //}
                    //else   //奇数行
                    //{
                    //    sb.Append("<tr class=\"two_tr\">"); //奇数行样式
                    //}

                    sb.Append("<tr>"); //加行数


                    for (int n = 0; n < colNum; n++)
                    {


                        sb.Append("<td>");
                        int currentCount = m * 5 + n;//当前所处条数

 

                        if (currentCount < nRowCount)//当前所处条数是否在数据量的有效范围内
                        {
                          
                            //添加表格内的内容
                        }
                        else
                        {
                            //置空
                            sb.Append("&nbsp;");
                        }

                        sb.Append("</td>");
                    }

                    sb.Append("</tr>");

                }

            }

            return sb.ToString();

        }

相关文章:

  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2021-09-16
  • 2022-03-03
  • 2021-10-02
  • 2021-09-08
相关资源
相似解决方案