protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { string sql3 = "select distinct Program,Date from [Working_hoursInfor] where SySe like '%" + Common.SySe + "%' and Program='" + Common.Program + "'"; DataTable program = Common.datatable(sql3); TableCellCollection header = e.Row.Cells; header.Clear(); string headtxt = "学号</th><th rowspan='2'>姓名</th>"; // headtxt += "<th colspan='"+program.Rows.Count+"'></th>"; //跨四列 headtxt += "<th rowspan='2'>班级</th>"; for (int i = 0; i < program.Rows.Count; i++) { DateTime Time = Convert.ToDateTime(program.Rows[i][1].ToString()); DateTime time = Time.Date; headtxt += "<th>" + time.ToString("yyyy-MM-dd"); // headtxt = headtxt.Substring(0, headtxt.Length - 5); //移除掉最后一个</th> } headtxt += "<th rowspan='2'>合计</th>"; headtxt += "<tr>"; for (int i = 0; i < program.Rows.Count; i++) { headtxt += "<th>" + program.Rows[i][0].ToString() + "</th>"; } headtxt += "</tr>"; TableHeaderCell cell = new TableHeaderCell(); cell.Attributes.Add("rowspan", "2"); //跨两行 cell.Text = (headtxt); header.Add(cell); } }
// 效益型性目标矩阵表头设置 protected void BenefitGrid_RowCreated(object sender, GridViewRowEventArgs e) { #region 给效益矩阵表头赋值 switch (e.Row.RowType) { case DataControlRowType.Header: //总表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //给表头命名 tcHeader.Add(new TableHeaderCell()); tcHeader[0].Text = ""; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Text = lsBenName[0]; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Text = lsBenName[1]; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Text = lsBenName[2]; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = lsBenName[3]; break; } #endregion }
// 适宜性准则矩阵2表头设置 protected void SuitfactGrid3_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //总表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //给表头命名 tcHeader.Add(new TableHeaderCell()); tcHeader[0].Text = ""; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Text = lsSuitName3[0]; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Text = lsSuitName3[1]; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Text = lsSuitName3[2]; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = lsSuitName3[3]; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Text = lsSuitName3[4]; break; } }
//GridView1多表头合并 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { //判断创建的行是否为表头行 if (e.Row.RowType == DataControlRowType.Header) { //获取表头所在行的所有单元格 TableCellCollection tcHeader = e.Row.Cells; //清除自动生成的表头 tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].ColumnSpan = 3; tcHeader[0].Text = "借方回款</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[1].Text = "回款时间"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Text = "回款金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Text = "备注</th></tr><tr>"; } }
protected void Grid_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection tcl = e.Row.Cells; tcl.Clear(); tcl.Add(new TableHeaderCell()); tcl[0].Text = "单位"; //tcl[0].Wrap = false; //tcl[0].Width = 100; tcl[0].HorizontalAlign = HorizontalAlign.Center; int n = 1; foreach (string k in dic.Keys) { tcl.Add(new TableHeaderCell()); tcl[n].Text = dic[k].Replace("#", "、").Replace("AA", "(").Replace("BB", ")"); tcl[n].Wrap = false; if (dic.Keys.Count > 13) { tcl[n].Width = 50; } n++; } } if (e.Row.RowType == DataControlRowType.Header) { e.Row.Attributes.Add("class", "HeadingRow"); } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "selectCol(this)"); e.Row.Cells[0].Wrap = true; } }
protected void gvBody_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: string[] Name = ColumnName.Split(','); TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); for (int j = 0; j <= 2; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Attributes.Add("rowspan", "2"); tcHeader[j].Text = Name[j].ToString(); tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); } tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("colspan", "2"); tcHeader[3].Text = Name[3].ToString(); tcHeader[3].Attributes.Add("bgcolor", "#F7F6F3"); tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("rowspan", "2"); tcHeader[4].Text = Name[4].ToString(); tcHeader[4].Attributes.Add("bgcolor", "#F7F6F3"); for (int j = 5; j <= 6; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Text = Name[j].ToString(); tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); } break; case DataControlRowType.DataRow: for (int i = 0; i < e.Row.Cells.Count; i++) { if (i == 0) { e.Row.Cells[0].Attributes.Add("align", "left"); } else { e.Row.Cells[i].Attributes.Add("align", "right"); } } //e.Row.Cells[e.Row.Cells.Count-1].Attributes.Add("align", "center"); //e.Row.Cells[e.Row.Cells.Count - 1].Style["font-weight"] = "bold"; break; case DataControlRowType.Footer: for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].Attributes.Add("bgcolor", "#efefe7"); e.Row.Cells[i].Attributes.Add("align", "right"); } break; } }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("rowspan", "2"); tcHeader[0].Text = "日期"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("rowspan", "2"); tcHeader[1].Text = "装备星级"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("colspan", "8"); tcHeader[2].Text = "职业"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("rowspan", "2"); tcHeader[3].Text = "总计</th></tr><tr style='color:White;background-color:#005652;font-size:12px;font-weight:bold;'>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = "虎贲"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("BackColor", "#005652"); tcHeader[5].Attributes.Add("ForeColor", "White"); tcHeader[5].Text = "浪人"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("BackColor", "#005652"); tcHeader[6].Attributes.Add("ForeColor", "White"); tcHeader[6].Text = "龙胆"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("BackColor", "#005652"); tcHeader[7].Attributes.Add("ForeColor", "White"); tcHeader[7].Text = "巧工"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("BackColor", "#005652"); tcHeader[8].Attributes.Add("ForeColor", "White"); tcHeader[8].Text = "气功师"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("BackColor", "#005652"); tcHeader[9].Attributes.Add("ForeColor", "White"); tcHeader[9].Text = "花灵"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("BackColor", "#005652"); tcHeader[10].Attributes.Add("ForeColor", "White"); tcHeader[10].Text = "天师"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("BackColor", "#005652"); tcHeader[11].Attributes.Add("ForeColor", "White"); tcHeader[11].Text = "行者"; break; } }
protected void gvCost_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["id"] = e.Row.RowIndex.ToString(); } if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; cells.Clear(); cells.Add(new TableHeaderCell()); cells[0].RowSpan = 2; cells[0].Text = "序号"; cells.Add(new TableHeaderCell()); cells[1].RowSpan = 2; cells[1].Text = "任务编码"; cells.Add(new TableHeaderCell()); cells[2].RowSpan = 2; cells[2].Text = "任务名称"; cells.Add(new TableHeaderCell()); cells[3].ColumnSpan = 4; cells[3].Text = "累计数</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 1; cells[4].Text = "合同预算"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 1; cells[5].Text = "实际成本"; cells.Add(new TableHeaderCell()); cells[6].RowSpan = 1; cells[6].Text = "盈亏"; cells[6].Attributes.Add("title", "盈亏 = 合同预算 – 实际成本"); cells[6].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[7].RowSpan = 1; cells[7].Attributes.Add("title", "盈亏率 = 盈亏 ÷ 合同预算"); cells[7].CssClass = "tooltip"; cells[7].Text = "盈亏率"; return; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Text = "合计"; string[] array = (string[])this.ViewState["Total"]; e.Row.Cells[3].Text = array[0]; e.Row.Cells[3].Style.Add("text-align", "right"); e.Row.Cells[3].CssClass = "decimal_input"; e.Row.Cells[4].Text = array[1]; e.Row.Cells[4].Style.Add("text-align", "right"); e.Row.Cells[4].CssClass = "decimal_input"; e.Row.Cells[5].Text = array[2]; e.Row.Cells[5].Style.Add("text-align", "right"); e.Row.Cells[5].CssClass = "decimal_input"; e.Row.Cells[6].Text = array[3]; e.Row.Cells[6].Style.Add("text-align", "right"); e.Row.Cells[6].CssClass = "decimal_input"; } }
//Grid_Detail多表头合并 protected void Grid_Detail_RowCreated(object sender, GridViewRowEventArgs e) { //判断创建的行是否为表头行 if (e.Row.RowType == DataControlRowType.Header) { //获取表头所在行的所有单元格 TableCellCollection tcHeader = e.Row.Cells; //清除自动生成的表头 tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].RowSpan = 2; tcHeader[0].Text = "序号"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].RowSpan = 2; tcHeader[1].Text = "异动日期"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].RowSpan = 2; tcHeader[2].Text = "工号"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].RowSpan = 2; tcHeader[3].Text = "姓名"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].RowSpan = 2; tcHeader[4].Text = "部门"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].RowSpan = 2; tcHeader[5].Text = "岗位"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].ColumnSpan = 4; tcHeader[6].Text = "异动情况"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].RowSpan = 2; tcHeader[7].Text = "操作员</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[8].Text = "原部门"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Text = "原岗位"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Text = "异动部门"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Text = "异动岗位"; } }
protected void grvTJ_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //总表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("rowspan", "2"); tcHeader[0].Text = "序号"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("rowspan", "2"); tcHeader[1].Text = "项目名称"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("colspan", "3"); tcHeader[2].Text = "收入"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("colspan", "3"); tcHeader[3].Text = "支出"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("rowspan", "2"); tcHeader[4].Text = "索赔金额</th></tr><tr>"; //tcHeader.Add(new TableHeaderCell()); //tcHeader[5].Attributes.Add("rowspan", "2"); //tcHeader[5].Text = "详细</th></tr><tr>"; //第二行表头 //<HeaderStyle BackColor="" Font-Bold="True" ForeColor="White" /> tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[5].Attributes.Add("color", "White"); tcHeader[5].Text = "项目金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[6].Attributes.Add("color", "White"); tcHeader[6].Text = "到款金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[7].Attributes.Add("color", "White"); tcHeader[7].Text = "收款比例"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[8].Attributes.Add("color", "Red"); tcHeader[8].Text = "合同金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[9].Attributes.Add("color", "Red"); tcHeader[9].Text = "支付金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("bgcolor", "#A8B7EC"); tcHeader[10].Attributes.Add("color", "White"); tcHeader[10].Text = "付款比例"; break; } }
//设计表头 protected void gvw_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header && Options.TableHeaderCell != null) { TableCellCollection header = e.Row.Cells; header.Clear(); header.Add(Options.TableHeaderCell); } }
protected void gvConstruct_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { e.Row.Attributes["id"] = this.gvConstruct.DataKeys[e.Row.RowIndex].Value.ToString(); } if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; cells.Clear(); cells.Add(new TableHeaderCell()); cells[0].RowSpan = 2; cells[0].Text = "序号"; cells.Add(new TableHeaderCell()); cells[1].RowSpan = 2; cells[1].Text = "项目编码"; cells.Add(new TableHeaderCell()); cells[2].RowSpan = 2; cells[2].Text = "项目名称"; cells.Add(new TableHeaderCell()); cells[3].RowSpan = 2; cells[3].Text = "计量单位"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 2; cells[4].Text = "工程量"; cells.Add(new TableHeaderCell()); cells[5].ColumnSpan = 2; cells[5].Text = "金额(元)"; cells.Add(new TableHeaderCell()); cells[6].ColumnSpan = 2; cells[6].Text = "上期末完成"; cells.Add(new TableHeaderCell()); cells[7].ColumnSpan = 2; cells[7].Text = "本期完成"; cells.Add(new TableHeaderCell()); cells[8].ColumnSpan = 2; cells[8].Text = "本期末完成</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[9].Text = "综合单价"; cells.Add(new TableHeaderCell()); cells[10].Text = "合计"; cells.Add(new TableHeaderCell()); cells[11].Text = "数量"; cells.Add(new TableHeaderCell()); cells[12].Text = "金额"; cells.Add(new TableHeaderCell()); cells[13].Text = "数量"; cells.Add(new TableHeaderCell()); cells[14].Text = "金额"; cells.Add(new TableHeaderCell()); cells[15].Text = "数量"; cells.Add(new TableHeaderCell()); cells[16].Text = "金额"; } }
protected void gvPayoutPlan_RowDataBound(object sender, GridViewRowEventArgs e) { if (base.Request["PlanType"].ToString() == "allplan" && e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; cells.Clear(); cells.Add(new TableHeaderCell()); cells[0].Attributes.Add("rowspan", "2"); cells[0].Text = "项目名称"; cells.Add(new TableHeaderCell()); cells[1].Attributes.Add("colspan", "2"); cells[1].Text = "上期计划金额"; cells.Add(new TableHeaderCell()); cells[2].Attributes.Add("colspan", "4"); cells[2].Text = "上期实际金额"; cells.Add(new TableHeaderCell()); cells[3].Attributes.Add("colspan", "2"); cells[3].Text = "本期计划金额</th></tr><tr>"; cells.Add(new TableHeaderCell()); cells[4].Text = "收入"; cells.Add(new TableHeaderCell()); cells[5].Text = "支出"; cells.Add(new TableHeaderCell()); cells[6].Text = "收入"; cells.Add(new TableHeaderCell()); cells[7].Text = "完成情况"; cells.Add(new TableHeaderCell()); cells[8].Text = "支出"; cells.Add(new TableHeaderCell()); cells[9].Text = "完成情况"; cells.Add(new TableHeaderCell()); cells[10].Text = "收入"; cells.Add(new TableHeaderCell()); cells[11].Text = "支出"; cells[4].Attributes["style"] = "background-color:#eef2f5"; cells[5].Attributes["style"] = "background-color:#eef2f5"; cells[6].Attributes["style"] = "background-color:#eef2f5"; cells[7].Attributes["style"] = "background-color:#eef2f5"; cells[8].Attributes["style"] = "background-color:#eef2f5"; cells[9].Attributes["style"] = "background-color:#eef2f5"; cells[10].Attributes["style"] = "background-color:#eef2f5"; cells[11].Attributes["style"] = "background-color:#eef2f5"; } if (e.Row.RowIndex > -1) { if (base.Request["PlanType"].ToString() == "allplan") { e.Row.Attributes["id"] = this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); e.Row.Attributes["guid"] = this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); return; } e.Row.Attributes["id"] = this.gvPayoutPlan.DataKeys[e.Row.RowIndex].Value.ToString(); e.Row.Attributes["guid"] = this.gvPayoutPlan.DataKeys[e.Row.RowIndex].Value.ToString(); } }
protected void gvBody_RowCreated(object sender, GridViewRowEventArgs e) { string HeaderStr = ""; switch (rblOrderBy.SelectedValue) { case "F": HeaderStr = "工厂;客户;合同号;GO NO; 合同单价(RMB/件);合同数量;标准单价(RMB/件);SAH(Sew+Iron&Pack);SAH(Sewing);预算平均单价(RMB/件);预算工厂平均单价(RMB/件);计划回货期"; break; case "C": HeaderStr = "客户;工厂;合同号;GO NO; 合同单价(RMB/件);合同数量;标准单价(RMB/件);SAH(Sew+Iron&Pack);SAH(Sewing);预算平均单价(RMB/件);预算工厂平均单价(RMB/件);计划回货期"; break; } switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); for (int i = 0; i < HeaderStr.Split(';').Length - 1; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Attributes.Add("rowspan", "2"); tcHeader[i].Text = HeaderStr.Split(';')[i].ToString(); } tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("colspan", "2"); tcHeader[11].Text = "差异1(合同价格-标准价格)"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Attributes.Add("colspan", "2"); tcHeader[12].Text = "差异2(合同价格-预算工厂平均价格)"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].Attributes.Add("rowspan", "2"); tcHeader[13].Text = "计划回货期</tr><tr>"; tcHeader.Add(new TableHeaderCell()); tcHeader[14].Text = "单价(RMB/件)"; tcHeader.Add(new TableHeaderCell()); tcHeader[15].Text = "金额(RMB)"; tcHeader.Add(new TableHeaderCell()); tcHeader[16].Text = "单价(RMB/件)"; tcHeader.Add(new TableHeaderCell()); tcHeader[17].Text = "金额(RMB)"; break; case DataControlRowType.DataRow: break; } }
protected void gvBody_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); for (int i = 0; i < 6; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Attributes.Add("rowspan", "2"); tcHeader[i].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i].Text = strHeader.Split(',')[i]; } DataTable dt = MESComment.MesOutSourcePriceSql.GetMarkerDetailTitle(txtMoNo.Text.Trim()); for (int i = 0; i < dt.Rows.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 6].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 6].Text = dt.Rows[i]["SIZE_CD"].ToString(); } tcHeader.Add(new TableHeaderCell()); tcHeader[dt.Rows.Count + 6].Attributes.Add("bgcolor", "#efefe7"); tcHeader[dt.Rows.Count + 6].Text = "Total</th></tr><tr>"; int total = 0; for (int i = 0; i < dt.Rows.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 6 + dt.Rows.Count + 1].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 6 + dt.Rows.Count + 1].Text = dt.Rows[i]["ORDER_QTY"].ToString(); total += dt.Rows[i]["ORDER_QTY"].ToString() == "" ? 0 : int.Parse(dt.Rows[i]["ORDER_QTY"].ToString()); } tcHeader.Add(new TableHeaderCell()); tcHeader[dt.Rows.Count * 2 + 6 + 1].Attributes.Add("bgcolor", "#efefe7"); //#efefe7 tcHeader[dt.Rows.Count * 2 + 6 + 1].Text = total.ToString(); break; case DataControlRowType.DataRow: gmtQty += int.Parse(e.Row.Cells[3].Text); plyQty += int.Parse(e.Row.Cells[4].Text); break; case DataControlRowType.Footer: e.Row.Cells[0].Text = "Total"; e.Row.Cells[3].Text = gmtQty.ToString(); e.Row.Cells[4].Text = plyQty.ToString(); for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].Attributes.Add("bgcolor", "#efefe7"); } break; } }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //行是标题行 TableCellCollection personHeader = e.Row.Cells; //标题行的单元格集合 personHeader.Clear(); //清空 personHeader.Add(new TableHeaderCell()); personHeader[0].Attributes.Add("rowspan", "2"); //跨2行 personHeader[0].Attributes.Add("colspan", "1"); //跨1列 personHeader[0].Text = "名称"; personHeader.Add(new TableHeaderCell()); personHeader[1].Attributes.Add("rowspan", "2"); //跨2行 personHeader[1].Attributes.Add("colspan", "1"); //跨1列 personHeader[1].Text = "上期库存"; int s = 2; for (int i = 0; i < 31; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s].Attributes.Add("colspan", "2"); personHeader[s].Text = "" + (i + 1) + "日"; s = s + 1; } personHeader.Add(new TableHeaderCell()); personHeader[s].Attributes.Add("colspan", "3"); //跨3列 personHeader[s].Text = "当期合计"; s = s + 1; personHeader.Add(new TableHeaderCell()); personHeader[s].Attributes.Add("rowspan", "2"); //跨2行 personHeader[s].Attributes.Add("colspan", "1"); //跨1列 personHeader[s].Text = "本期库存</th></tr><tr>"; s = s + 1; for (int i = 0; i < 32; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s].Text = "增"; s = s + 1; personHeader.Add(new TableHeaderCell()); personHeader[s].Text = "耗"; s = s + 1; } personHeader.Add(new TableHeaderCell()); personHeader[s].Text = "小计"; break; } }
//合并表头 protected void Merge_Header(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection tcHeader = e.Row.Cells; //清除自动生成的表头 tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].RowSpan = 2; tcHeader[0].Text = "编号"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].RowSpan = 2; tcHeader[1].Text = "类型"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].RowSpan = 2; tcHeader[2].Text = "床位数"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].ColumnSpan = 5; tcHeader[3].Text = "客房配置"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].RowSpan = 2; tcHeader[4].Text = "备注"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].RowSpan = 2; tcHeader[5].ColumnSpan = 2; tcHeader[5].Text = "操作</th></tr><tr>"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Text = "空调"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Text = "电视机"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Text = "电吹风"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Text = "电话"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Text = "WIFI"; //背表头颜色 for (int i = 0; i < 11; i++) { tcHeader[i].BackColor = System.Drawing.Color.Blue; tcHeader[i].ForeColor = System.Drawing.Color.White; } } }
protected void gvStageSchedule_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; cells.Clear(); cells.Add(new TableHeaderCell()); cells[0].Attributes.Add("rowspan", "2"); cells[0].Style.Add("width", "40px"); cells[0].Text = "项目名称"; cells.Add(new TableHeaderCell()); cells[1].Attributes.Add("rowspan", "2"); cells[1].Style.Add("width", "40px"); cells[1].Text = "uid"; cells.Add(new TableHeaderCell()); cells[2].Attributes.Add("rowspan", "2"); cells[2].Style.Add("width", "40px"); cells[2].Text = "prjID"; cells.Add(new TableHeaderCell()); cells[3].Attributes.Add("rowspan", "2"); cells[3].Style.Add("width", "40px"); cells[3].Text = "PrjCode"; this.dt = publicDbOpClass.DataTableQuary("\r\n select codeID,codeName from XPM_Basic_CodeList where TypeID IN (\r\n SELECT typeId FROM XPM_Basic_CodeType\r\n WHERE SignCode='Img'\r\n ) and [IsValid]='true' and ChildNumber=0 order by I_xh\r\n "); int count = this.dt.Rows.Count; for (int i = 0; i < count; i++) { cells.Add(new TableHeaderCell()); cells[i + 4].Attributes.Add("colspan", "3"); cells[i + 4].Text = this.dt.Rows[i]["codename"].ToString(); } TableCell expr_200 = cells[cells.Count - 1]; expr_200.Text += "</th></tr><tr class=\"header\">"; for (int j = 0; j < count; j++) { cells.Add(new TableHeaderCell()); if (j == 0) { cells[cells.Count - 1].Text = "计划日期"; } else { cells[cells.Count - 1].Text = "计划日期"; } cells.Add(new TableHeaderCell()); cells[cells.Count - 1].Text = "实际日期"; cells.Add(new TableHeaderCell()); cells[cells.Count - 1].Text = "状态"; } TableCell expr_2BE = cells[cells.Count - 1]; expr_2BE.Text += "</tr>"; } }
protected void gvBody_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //First Row if (CbProcessCloseStatus.Checked) { for (int i = 0; i < headTitle.Length; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = headTitle[i]; } } else { for (int i = 0; i < headTitle.Length - 2; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = headTitle[i]; } } break; } if (e.Row.RowIndex >= 0) { //每次添加列的时候都要注意是否影响到这里的总计; totalOutQty += Convert.ToInt32(e.Row.Cells[13].Text); //Modified by MunFoong on 2014.07.24, MES-135 //Modified by Zikuan MES-069 totalOpening += Convert.ToInt32(e.Row.Cells[11].Text); //Modified by MunFoong on 2014.07.24, MES-135 //End Modified MES-069 if (CbProcessCloseStatus.Checked) { totalWipQty += Convert.ToInt32(e.Row.Cells[e.Row.Cells.Count - 3].Text); } else { totalWipQty += Convert.ToInt32(e.Row.Cells[e.Row.Cells.Count - 1].Text); } } lblTotalWipQty.Text = totalWipQty.ToString(); lblTotalOutQty.Text = totalOutQty.ToString(); //Modified by MF on 20160126,dCT formula change to Day End WIP/ WIP out //lblCT.Text = totalOutQty.Equals(0) ? "0" : (((double.Parse(totalWipQty.ToString()) + (double.Parse(totalOpening.ToString()))) / 2) / double.Parse(totalOutQty.ToString())).ToString("f4"); lblCT.Text = totalOutQty.Equals(0) ? "0" : (double.Parse(totalWipQty.ToString()) / double.Parse(totalOutQty.ToString())).ToString("f4"); //End of modified by MF on 20160126,dCT formula change to Day End WIP/ WIP out }
protected void gvList_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) //判断创建的行是不是标题行 { TableCellCollection cells = e.Row.Cells; cells.Clear(); //获得标题行,清空标题行的设置 cells.Add(new TableHeaderCell()); //添加一个标题单元 cells[0].RowSpan = 12; //设置跨行. //直接导入html中的table中的元素 cells[0].Text = @"</th><th colspan=3>OA系统+金蝶系统</th><th colspan=6>OA系统</th><th colspan=4>金蝶系统</th></tr><tr style='height: 20px; background-color: #336699; color: White;'> <th> 发票号 </th> <th> 客户名称 </th> <th> 金额 </th> <th> 发票号 </th> <th> 客户名称 </th> <th> AE </th> <th> 金额 </th> <th> 日期 </th> <th> 项目编号 </th> <th> 发票号 </th> <th> 客户名称 </th> <th> 金额 </th> <th> 日期 "; } }
//Grid_Detail多表头合并 protected void Grid_Detail_RowCreated(object sender, GridViewRowEventArgs e) { //判断创建的行是否为表头行 if (e.Row.RowType == DataControlRowType.Header) { //获取表头所在行的所有单元格 TableCellCollection tcHeader = e.Row.Cells; //清除自动生成的表头 tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].RowSpan = 2; tcHeader[0].Text = "序号"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].RowSpan = 2; tcHeader[1].Text = "工序"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].RowSpan = 2; tcHeader[2].Text = "计件系列"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].RowSpan = 2; tcHeader[3].Text = "计件项目"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].RowSpan = 2; tcHeader[4].Text = "单价"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].ColumnSpan = 4; tcHeader[5].Text = "调整情况</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[6].Text = "原单价"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Text = "现单价"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Text = "调整金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Text = "调整比率(%)"; } }
protected void gvTemp_RowCreated(object sender, GridViewRowEventArgs e) { //判断创建的行是否为表头行 if (e.Row.RowType == DataControlRowType.Header) { //获取表头所在行的所有单元格 TableCellCollection tcHeader = e.Row.Cells; //清除自动生成的表头 tcHeader.Clear(); //新添加的第一个表头单元格, 设置为合并7个列, 从而形成一行. tcHeader.Add(new TableHeaderCell()); tcHeader[0].ColumnSpan = 8; } }
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { TableCellCollection tcc = e.Row.Cells; tcc.Clear(); e.Row.Cells.Add(new TableCell()); e.Row.Cells[0].Attributes.Add("colspan", "3"); e.Row.Cells[0].Text = "总交易数"; e.Row.Cells[0].Font.Bold = true; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells.Add(new TableCell()); e.Row.Cells[1].Text = "";// e.Row.Cells.Add(new TableCell()); e.Row.Cells[2].Text = "总收入";// e.Row.Cells[2].Font.Bold = true; e.Row.Cells.Add(new TableCell()); e.Row.Cells[3].Text = "";// e.Row.Cells.Add(new TableCell()); e.Row.Cells[4].Attributes.Add("colspan", "5"); e.Row.Cells[4].Text = ""; e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells.Add(new TableCell()); } if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { #region 设置GridView列的属性为文本,便于导出excel时显示正常 e.Row.Cells[0].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[1].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[3].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[4].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[6].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[10].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[11].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[13].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[14].Visible = false; e.Row.Cells[9].Visible = false; e.Row.Cells[10].Visible = false; #endregion } }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("colspan", "5"); tcHeader[0].CssClass = "gridviewHeader"; tcHeader[0].Text = "待播清單 (" + ((HiddenField)this.Parent.FindControl("BootstrapResponsiveMode")).Value + ") [歌庫: " + GuiGlobal.AllSongDT.Rows.Count + "]"; break; } }
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { TableCellCollection tcc = e.Row.Cells; tcc.Clear(); e.Row.Cells.Add(new TableCell()); e.Row.Cells[0].Attributes.Add("colspan", "4"); e.Row.Cells[0].Text = "总交易数"; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells.Add(new TableCell()); e.Row.Cells[1].Text = "";// e.Row.Cells.Add(new TableCell()); e.Row.Cells[2].Text = "总收入";// e.Row.Cells.Add(new TableCell()); e.Row.Cells[3].Text = "";// e.Row.Cells.Add(new TableCell()); e.Row.Cells[4].Attributes.Add("colspan", "8"); e.Row.Cells[4].Text = ""; e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells.Add(new TableCell()); } if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[0].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[1].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[3].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[4].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[10].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[11].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); e.Row.Cells[12].Visible = false; e.Row.Cells[16].Visible = false; e.Row.Cells[17].Visible = false; e.Row.Cells[18].Visible = false; e.Row.Cells[19].Visible = false; } //if (e.Row.RowType == DataControlRowType.Header) //{ // e.Row.Cells[1].Text = "3333"; //} }
protected void gvBody_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable dtTitle = MESComment.MesOutSourcePriceSql.GetMarkerCSBreakdownTitle(txtMoNo.Text.Trim()); switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Text = "Color/Pattern"; tcHeader[0].Attributes.Add("bgcolor", "#efefe7"); for (int i = 0; i < dtTitle.Rows.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 1].Text = dtTitle.Rows[i]["MARKER_ID"].ToString(); } tcHeader.Add(new TableHeaderCell()); tcHeader[dtTitle.Rows.Count + 1].Text = "Totals"; tcHeader[dtTitle.Rows.Count + 1].Attributes.Add("bgcolor", "#efefe7"); break; case DataControlRowType.DataRow: sumValue = 0; for (int i = 0; i < dtTitle.Rows.Count; i++) { sumValue += MesRpt.ParseInt(e.Row.Cells[i + 1].Text.Trim()) * MesRpt.ParseInt(dtTitle.Rows[i]["TOTAL_RATION"].ToString()); } e.Row.Cells[dtTitle.Rows.Count + 1].Text = sumValue.ToString(); for (int i = 0; i <= dtTitle.Rows.Count; i++) { value[i] += MesRpt.ParseInt(e.Row.Cells[i + 1].Text.ToString()); } break; case DataControlRowType.Footer: e.Row.Cells[0].Text = "Totals(Plies)"; for (int i = 0; i <= dtTitle.Rows.Count; i++) { e.Row.Cells[i + 1].Text = value[i].ToString(); } break; } }
protected void Grid_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { DataTable dtGroup = GetGroupHeader(); TableCellCollection tcl = e.Row.Cells; tcl.Clear(); tcl.Add(new TableHeaderCell()); tcl[0].Text = "单位"; tcl[0].Wrap = false; tcl[0].RowSpan = 2; tcl.Add(new TableHeaderCell()); tcl[1].Text = "班组长总数"; tcl[1].Wrap = false; tcl[1].RowSpan = 2; tcl.Add(new TableHeaderCell()); tcl[2].Text = "其中</th></tr>"; tcl[2].Wrap = false; tcl[2].ColumnSpan = dtGroup.Rows.Count; int n = 3; foreach (DataRow r in dtGroup.Rows) { tcl.Add(new TableHeaderCell()); tcl[n].Text = r["LEVEL_NAME"].ToString(); tcl[n].Wrap = false; n++; } } if (e.Row.RowType == DataControlRowType.Header) { e.Row.Attributes.Add("class", "HeadingRow"); } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "selectCol(this)"); } }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Text = "用户名"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Text = "权限"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Text = "所属机构"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("colspan", "2"); tcHeader[3].Text = "操作"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = "重置密码"; break; } }
protected void gvBody_RowDataBoundDct(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //First Row for (int i = 0; i < DetheadTitle.Length; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = DetheadTitle[i]; } break; } //Added by Jin Song MES115 if (e.Row.Cells[1].Text == "ALL" || e.Row.Cells[0].Text == "Total DCT:") { e.Row.Font.Bold = true; e.Row.ForeColor = System.Drawing.Color.Black; } //End of Add MES115 }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { //判断是否表头 case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("rowspan", "2"); tcHeader[0].Attributes.Add("bgcolor", "Azure"); tcHeader[0].Text = "用户ID"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("colspan", "4"); tcHeader[1].Attributes.Add("bgcolor", "Azure"); tcHeader[1].Text = "基 本 信 息</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("bgcolor", "Azure"); tcHeader[2].Text = "用户姓名"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("bgcolor", "Azure"); tcHeader[3].Text = "性别"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("bgcolor", "Azure"); tcHeader[4].Text = "家庭住址"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "Azure"); tcHeader[5].Text = "邮政编码"; break; } }