zoukankan      html  css  js  c++  java
  • 动态生成HtmlTable表格

    protected void btn_output_Click(object sender, EventArgs e)
        {
            //OutPutByGridview();
            PanelOutput();
        }

        private void PanelOutput()
        {
            DataSet ds = u.GetOutTableData("");
            if(ds != null && ds.Tables[0].Rows.Count !=0)
            {
                //加表头
                HtmlTableRow trhead = new HtmlTableRow();
                for (int k = 0; k < ds.Tables[0].Columns.Count; k++)
                {

                    HtmlTableCell tchead = new HtmlTableCell();
                    tchead.InnerText = ds.Tables[0].Columns[k].ColumnName;
                    trhead.Cells.Add(tchead);
                }
                this.tbout.Rows.Add(trhead);
                //表的内容
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    HtmlTableRow tr = new HtmlTableRow();
                    for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                    {
                        HtmlTableCell tc = new HtmlTableCell();
                        tc.InnerText = ds.Tables[0].Rows[i][j].ToString();
                        //switch (j)
                        //{
                        //    case 0:
                        //        tc.InnerText = ds.Tables[0].Rows[i]["name"].ToString();
                        //        break;
                        //    case 1:
                        //        tc.InnerText = ds.Tables[0].Rows[i]["Age"].ToString();
                        //        break;
                        //    case 2:
                        //        tc.InnerText = ds.Tables[0].Rows[i]["Sex"].ToString();
                        //        break;
                        //    default:
                              
                        //        break;
                        //}
                      
                      
                        tr.Cells.Add(tc);
                    }
                    this.tbout.Rows.Add(tr);

                }

            }
            Comm.OutPutExcel(plOut3);
          
        }

  • 相关阅读:
    vc++ 错误 CreateWindow
    设置某个页面的编码方式
    部署Struts2框架
    oracle之约束
    java web开发(三)、Ajax技术
    vs2008 安装出错 Microsoft Visual Studio Web 组件安装失败
    java web开发(二)、Servlet技术
    WLS Zip Distribution for Oracle WebLogic Server 12.1.1.0安装
    MyEclipse配置Weblogic服务器
    js 未结束的字符串常量错误解决方法
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763492.html
Copyright © 2011-2022 走看看