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:#006699;font-size:12px;font-weight:bold;'>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = "虎贲"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("BackColor", "#006699"); tcHeader[5].Attributes.Add("ForeColor", "White"); tcHeader[5].Text = "浪人"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("BackColor", "#006699"); tcHeader[6].Attributes.Add("ForeColor", "White"); tcHeader[6].Text = "龙胆"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("BackColor", "#006699"); tcHeader[7].Attributes.Add("ForeColor", "White"); tcHeader[7].Text = "巧工"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("BackColor", "#006699"); tcHeader[8].Attributes.Add("ForeColor", "White"); tcHeader[8].Text = "斗仙"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("BackColor", "#006699"); tcHeader[9].Attributes.Add("ForeColor", "White"); tcHeader[9].Text = "花灵"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("BackColor", "#006699"); tcHeader[10].Attributes.Add("ForeColor", "White"); tcHeader[10].Text = "天师"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("BackColor", "#006699"); 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 = "本月数"; cells.Add(new TableHeaderCell()); cells[4].ColumnSpan = 4; cells[4].Text = "累计数</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 1; cells[5].Text = "目标成本"; cells.Add(new TableHeaderCell()); cells[6].RowSpan = 1; cells[6].Text = "实际成本"; cells.Add(new TableHeaderCell()); cells[7].RowSpan = 1; cells[7].Text = "降低额"; cells[7].Attributes.Add("title", "降低额 = 目标成本 – 实际成本"); cells[7].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[8].RowSpan = 1; cells[8].Text = "降低率"; cells[8].Attributes.Add("title", "降低率 = 降低额 ÷ 目标成本"); cells[8].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[9].RowSpan = 1; cells[9].Text = "目标成本"; cells.Add(new TableHeaderCell()); cells[10].RowSpan = 1; cells[10].Text = "实际成本"; cells.Add(new TableHeaderCell()); cells[11].RowSpan = 1; cells[11].Text = "降低额"; cells[11].Attributes.Add("title", "降低额 = 目标成本 – 实际成本"); cells[11].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[12].RowSpan = 1; cells[12].Text = "降低率"; cells[12].Attributes.Add("title", "降低率 = 降低额 ÷ 目标成本"); cells[12].CssClass = "tooltip"; } if (e.Row.RowType == DataControlRowType.Footer) { string[] array = (string[])this.ViewState["Total"]; e.Row.Cells[1].Text = "合计"; 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"; e.Row.Cells[7].Text = array[4]; e.Row.Cells[7].Style.Add("text-align", "right"); e.Row.Cells[7].CssClass = "decimal_input"; e.Row.Cells[8].Text = array[5]; e.Row.Cells[8].Style.Add("text-align", "right"); e.Row.Cells[8].CssClass = "decimal_input"; e.Row.Cells[9].Text = array[6]; e.Row.Cells[9].Style.Add("text-align", "right"); e.Row.Cells[9].CssClass = "decimal_input"; e.Row.Cells[10].Text = array[7]; e.Row.Cells[10].Style.Add("text-align", "right"); e.Row.Cells[10].CssClass = "decimal_input"; } }
protected void GridInfo_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].RowSpan = 2; tcl[0].ColumnSpan = 2; tcl[0].Width = 300; tcl.Add(new TableHeaderCell()); tcl[1].Text = "总计(人)"; tcl[1].Wrap = false; tcl[1].RowSpan = 2; tcl[1].Width = 40; tcl.Add(new TableHeaderCell()); tcl[2].Text = "年龄结构"; tcl[2].Wrap = false; tcl[2].ColumnSpan = 4; tcl.Add(new TableHeaderCell()); tcl[3].Text = "学历结构"; tcl[3].Wrap = false; tcl[3].ColumnSpan = eduTblCount; tcl.Add(new TableHeaderCell()); tcl[4].Text = "技术职称"; tcl[4].Wrap = false; tcl[4].ColumnSpan = techTitleCount; tcl.Add(new TableHeaderCell()); tcl[5].Text = "技能等级</th></tr>"; tcl[5].Wrap = false; tcl[5].ColumnSpan = techTblCount; tcl.Add(new TableHeaderCell()); tcl[6].Text = "30岁及以下"; tcl[6].Wrap = false; tcl[6].Width = 40; tcl.Add(new TableHeaderCell()); tcl[7].Text = "31-40岁"; tcl[7].Wrap = false; tcl[7].Width = 40; tcl.Add(new TableHeaderCell()); tcl[8].Text = "41-50岁"; tcl[8].Wrap = false; tcl[8].Width = 40; tcl.Add(new TableHeaderCell()); tcl[9].Text = "51岁及以上"; tcl[9].Wrap = false; tcl[9].Width = 40; tcl.Add(new TableHeaderCell()); tcl[10].Text = "未填"; tcl[10].Wrap = false; tcl[10].Width = 40; int n = 11; DataTable dtEdu = GetEducationLevel(); foreach (DataRow r in dtEdu.Rows) { tcl.Add(new TableHeaderCell()); tcl[n].Text = r["EDUCATION_LEVEL_NAME"].ToString(); //tcl[n].Wrap = false; tcl[n].Width = 40; n++; } DataTable dtTitle = GetTechnicianTitle(); tcl.Add(new TableHeaderCell()); tcl[n].Text = "小计"; tcl[n].Wrap = false; tcl[n].Width = 40; n++; tcl.Add(new TableHeaderCell()); tcl[n].Text = "未填"; tcl[n].Wrap = false; tcl[n].Width = 40; n++; foreach (DataRow r in dtTitle.Rows) { tcl.Add(new TableHeaderCell()); tcl[n].Text = r["type_name"].ToString(); //tcl[n].Wrap = false; tcl[n].Width = 40; n++; } DataTable dtTech = GetTechnician(); tcl.Add(new TableHeaderCell()); tcl[n].Text = "小计"; tcl[n].Wrap = false; tcl[n].Width = 40; n++; tcl.Add(new TableHeaderCell()); tcl[n].Text = "未填"; tcl[n].Wrap = false; tcl[n].Width = 40; n++; foreach (DataRow r in dtTech.Rows) { tcl.Add(new TableHeaderCell()); tcl[n].Text = r["type_name"].ToString(); //tcl[n].Wrap = false; tcl[n].Width = 40; 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 = false; e.Row.Cells[1].Wrap = false; } }
//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 = "发货ID"; tcHeader[0].Visible = false; tcHeader.Add(new TableHeaderCell()); tcHeader[1].RowSpan = 2; tcHeader[1].Text = "发货时间"; tcHeader[1].Width = 20; tcHeader.Add(new TableHeaderCell()); tcHeader[2].RowSpan = 2; tcHeader[2].Text = "客户名称"; tcHeader[2].Width = 20; tcHeader.Add(new TableHeaderCell()); tcHeader[3].RowSpan = 2; tcHeader[3].Text = "产品型号"; tcHeader[3].Width = 20; tcHeader.Add(new TableHeaderCell()); tcHeader[4].RowSpan = 2; tcHeader[4].Text = "产品备注"; tcHeader[4].Width = 20; tcHeader.Add(new TableHeaderCell()); tcHeader[5].ColumnSpan = 5; tcHeader[5].Text = "借方"; tcHeader[5].Width = 200; tcHeader.Add(new TableHeaderCell()); tcHeader[6].ColumnSpan = 4; tcHeader[6].Width = 200; tcHeader[6].Text = "开票信息</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[7].Text = "送货数量"; tcHeader[7].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Text = "退货数量"; tcHeader[8].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Text = "订单单价"; tcHeader[9].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Text = "发货总额"; tcHeader[10].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Text = "已付款金额"; tcHeader[11].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Text = "开票日期"; tcHeader[12].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[13].Text = "开票数量"; tcHeader[13].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[14].Text = "开票单价"; tcHeader[14].Width = 50; tcHeader.Add(new TableHeaderCell()); tcHeader[15].Text = "金额"; tcHeader[15].Width = 50; } }
protected void grdvw_ZKList_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[0].Attributes.Add("rowspan", "2"); //跨Row tcHeader[0].Attributes.Add("colspan", "0"); //跨Column tcHeader[0].Text = "ID"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[1].Attributes.Add("rowspan", "2"); //跨Row tcHeader[1].Attributes.Add("colspan", "0"); //跨Column tcHeader[1].Text = "分析项目ID"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[2].Attributes.Add("rowspan", "2"); //跨Row tcHeader[2].Attributes.Add("colspan", "0"); //跨Column tcHeader[2].Text = "分析项目"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[3].Attributes.Add("rowspan", "2"); //跨Row tcHeader[3].Attributes.Add("colspan", "0"); //跨Column tcHeader[3].Text = "分析者"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[4].Attributes.Add("rowspan", "2"); //跨Row tcHeader[4].Attributes.Add("colspan", "0"); //跨Column tcHeader[4].Text = "分析样品数"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[5].Attributes.Add("rowspan", "0"); //跨Row tcHeader[5].Attributes.Add("colspan", "4"); //跨Column tcHeader[5].Text = "现场平行样"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[6].Attributes.Add("rowspan", "0"); //跨Row tcHeader[6].Attributes.Add("colspan", "4"); //跨Column tcHeader[6].Text = "实验室平行样"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[7].Attributes.Add("rowspan", "0"); //跨Row tcHeader[7].Attributes.Add("colspan", "4"); //跨Column tcHeader[7].Text = "加标回收"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[8].Attributes.Add("rowspan", "0"); //跨Row tcHeader[8].Attributes.Add("colspan", "2"); //跨Column tcHeader[8].Text = "全程序空白"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[9].Attributes.Add("rowspan", "0"); //跨Row tcHeader[9].Attributes.Add("colspan", "2"); //跨Column tcHeader[9].Text = "密码样"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[10].Attributes.Add("rowspan", "0"); //跨Row tcHeader[10].Attributes.Add("colspan", "2"); //跨Column tcHeader[10].Text = "标样"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[11].Attributes.Add("rowspan", "2"); //跨Row tcHeader[11].Attributes.Add("colspan", "0"); //跨Column tcHeader[11].Text = "总检数</tr><tr>"; int n = 12; //第二行表头 int p = 0; for (int i = 0; i < 6; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[n + i + p].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[n + i + p].Attributes.Add("rowspan", "0"); //跨Row tcHeader[n + i + p].Attributes.Add("colspan", "0"); //跨Column tcHeader[n + i + p].Text = "检查数"; if (i < 3) { p++; tcHeader.Add(new TableHeaderCell()); tcHeader[n + i + p].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[n + i + p].Attributes.Add("rowspan", "0"); //跨Row tcHeader[n + i + p].Attributes.Add("colspan", "0"); //跨Column tcHeader[n + i + p].Text = "检查率%"; } p++; tcHeader.Add(new TableHeaderCell()); tcHeader[n + i + p].Attributes.Add("rowspan", "0"); //跨Row tcHeader[n + i + p].Attributes.Add("colspan", "0"); //跨Column tcHeader[n + i + p].Text = "合格数"; tcHeader[n + i + p].Attributes.Add("bgcolor", "#005EBB"); if (i < 3) { p++; tcHeader.Add(new TableHeaderCell()); tcHeader[n + i + p].Attributes.Add("rowspan", "0"); //跨Row tcHeader[n + i + p].Attributes.Add("colspan", "0"); //跨Column tcHeader[n + i + p].Text = "合格率%"; tcHeader[n + i + p].Attributes.Add("bgcolor", "#005EBB"); } if (n + i + p == 17) { tcHeader[n + i + p].Text = "合格数</tr><tr>"; } } } if (e.Row.RowType == DataControlRowType.DataRow) { } if (e.Row.RowType != DataControlRowType.Pager) { //////绑定数据后,隐藏4,5,6,7列 e.Row.Cells[0].Visible = false; e.Row.Cells[1].Visible = false; //e.Row.Cells[12].Visible = false; // e.Row.Cells[18].Visible = false; //for (int i = 8; i <= e.Row.Cells.Count-1; i++) //{ // e.Row.Cells[i].Visible = false; //} //e.Row.Cells[3].Visible = false; //e.Row.Cells[6].Visible = false; //e.Row.Cells[10].Visible = false; //e.Row.Cells[15].Visible = false; //e.Row.Cells[16].Visible = false; //e.Row.Cells[17].Visible = false; //e.Row.Cells[20].Visible = false; //e.Row.Cells[21].Visible = false; //e.Row.Cells[18].Visible = false; //for (int i = 0; i < cbl_choose.Items.Count; i++) //{ // if (!cbl_choose.Items[i].Selected) // { // try // { // int p = int.Parse(cbl_choose.Items[i].Value); // e.Row.Cells[p].Visible = false; // } // catch // { } // } //} } }
protected void gvwContract_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; cells.Clear(); cells.Add(new TableHeaderCell()); cells[0].CssClass = "header"; cells[0].RowSpan = 2; cells[0].Text = "序号"; cells.Add(new TableHeaderCell()); cells[1].CssClass = "header"; cells[1].RowSpan = 2; cells[1].Text = "项目名称"; cells.Add(new TableHeaderCell()); cells[2].CssClass = "header"; cells[2].ColumnSpan = 7; cells[2].Text = "收入合同"; cells.Add(new TableHeaderCell()); cells[3].CssClass = "header"; cells[3].ColumnSpan = 7; cells[3].Text = "支出合同"; cells.Add(new TableHeaderCell()); cells[4].CssClass = "header"; cells[4].RowSpan = 2; cells[4].Text = "原合同差额"; cells.Add(new TableHeaderCell()); cells[5].CssClass = "header"; cells[5].RowSpan = 2; cells[5].Text = "变更后合同差额"; cells.Add(new TableHeaderCell()); cells[6].CssClass = "header"; cells[6].RowSpan = 2; cells[6].Text = "结算差额"; cells.Add(new TableHeaderCell()); cells[7].CssClass = "header"; cells[7].RowSpan = 2; cells[7].Text = "支付差额</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[8].RowSpan = 1; cells[8].Text = "合同编号"; cells.Add(new TableHeaderCell()); cells[9].RowSpan = 1; cells[9].Text = "合同名称"; cells.Add(new TableHeaderCell()); cells[10].RowSpan = 1; cells[10].Text = "原始金额"; cells.Add(new TableHeaderCell()); cells[11].RowSpan = 1; cells[11].Text = "变更后金额"; cells.Add(new TableHeaderCell()); cells[12].RowSpan = 1; cells[12].Text = "开累结算"; cells.Add(new TableHeaderCell()); cells[13].RowSpan = 1; cells[13].Text = "开累回款"; cells.Add(new TableHeaderCell()); cells[14].RowSpan = 1; cells[14].Text = "挂靠项目开累付款"; cells.Add(new TableHeaderCell()); cells[15].RowSpan = 1; cells[15].Text = "合同编号"; cells.Add(new TableHeaderCell()); cells[16].RowSpan = 1; cells[16].Text = "合同名称"; cells.Add(new TableHeaderCell()); cells[17].RowSpan = 1; cells[17].Text = "合同类型"; cells.Add(new TableHeaderCell()); cells[18].RowSpan = 1; cells[18].Text = "原始金额"; cells.Add(new TableHeaderCell()); cells[19].RowSpan = 1; cells[19].Text = "变更后金额"; cells.Add(new TableHeaderCell()); cells[20].RowSpan = 1; cells[20].Text = "开累结算"; cells.Add(new TableHeaderCell()); cells[21].RowSpan = 1; cells[21].Text = "开累支付"; } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //e.Row.Attributes.Add("onmouseout", "if(this.style.backgroundColor='Gray') {this.style.backgroundColor=\"" + e.Row.Style["BACKGROUND-COLOR"] + "\";}"); //e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=\"" + "Gray" + "\""); e.Row.Style.Add(HtmlTextWriterStyle.Cursor, "hand"); e.Row.ToolTip = "点击一次,可以变色"; e.Row.Attributes.Add("onclick", "if(this.style.backgroundColor==''){this.style.backgroundColor='#eaeaea';this.title='再点一次,可以去色';}else{this.style.backgroundColor='';this.title='点击一次,可以变色';}"); DataRowView drv = (DataRowView)e.Row.DataItem; for (int i = 0; i < drv.DataView.Table.Columns.Count; i++) { if (listFootSum.Count <= i) { listFootSum.Add(""); } if (drv[i].GetType() == typeof(DateTime)) { DateTime dtTime = Convert.ToDateTime(drv[i]); if (dtTime.Hour == 0 && dtTime.Minute == 0 && dtTime.Second == 0) { e.Row.Cells[i + 1].Text = Convert.ToDateTime(drv[i]).ToString("yyyy-MM-dd"); } } else if (drv[i].GetType() != typeof(string)) { e.Row.Cells[i + 1].Text = ChangeDataFormat(e.Row.Cells[i + 1].Text); e.Row.Cells[i + 1].CssClass = "fontForRight"; if (null == drv[i]) { drv[i] = 0; } if (string.IsNullOrEmpty(listFootSum[i])) { listFootSum[i] = ""; } if ( drv[i].GetType() == typeof(int) || drv[i].GetType() == typeof(float) || drv[i].GetType() == typeof(decimal) || drv[i].GetType() == typeof(double) ) { e.Row.Cells[i + 1].Text = ChangeDataFormat(e.Row.Cells[i + 1].Text); if (listCalculateField.Contains(drv.Row.Table.Columns[i].ColumnName.Trim())) { if (string.IsNullOrEmpty(listFootSum[i])) { listFootSum[i] = "0"; } double tmpValue = Convert.ToDouble(drv[i]) + Convert.ToDouble(listFootSum[i]); listFootSum[i] = tmpValue.ToString(); } } } if ( (e.Row.Cells[i].Text.Trim().StartsWith("-") && e.Row.Cells[i].Text.Trim().LastIndexOf("-") > 0) || (e.Row.Cells[i].Text.Trim().StartsWith("0") && !e.Row.Cells[i].Text.Trim().StartsWith("0.") && e.Row.Cells[i].Text.Trim().Length > 3) ) { e.Row.Cells[i].Text = "'" + e.Row.Cells[i].Text; } else if (e.Row.Cells[i].Text.Trim().StartsWith(@"\\") || e.Row.Cells[i].Text.Trim().ToLower().StartsWith(@"http:\\")) { string strPath = e.Row.Cells[i].Text.Trim(); e.Row.Cells[i].Text = string.Format("<a href='{0}'>{1}</a>", strPath, strPath.Substring(strPath.LastIndexOf("\\") + 1)); } #region 功能控制 // 1. 首行重复项是否不显 if (reportFuncCode != 1) { if (i == 1) { if (UpRowData == e.Row.Cells[1].Text) { e.Row.Cells[1].Text = ""; } else { UpRowData = e.Row.Cells[1].Text; } } } #endregion } needSetFormat = false; } else if (e.Row.RowType == DataControlRowType.Footer) { //if (isShowFoot) { TableCellCollection tcFoot = e.Row.Cells; tcFoot.Clear(); tcFoot.Add(new TableHeaderCell()); tcFoot[0].Text = "合计"; tcFoot[0].CssClass = "strongFont"; tcFoot[0].Attributes.Add("colspan", "2"); //DataRowView drv = (DataRowView)e.Row.DataItem; //for (int i = 1; i < drv.Row.Table.Columns.Count; i++) //{ // tcFoot.Add(new TableHeaderCell()); // tcFoot[i].CssClass = "fontForRight"; // if (drv[i].GetType() == typeof(int) || drv[i].GetType() == typeof(decimal) || // drv[i].GetType() == typeof(float) || drv[i].GetType() == typeof(double)) // { // tcFoot[i].Text = dsCurrent.Tables[0].Compute("SUM(" + drv.Row.Table.Columns[i].ColumnName + ")", drv.Row.Table.Columns[i].ColumnName + " is not null and " + drv.Row.Table.Columns[i].ColumnName + ">0").ToString(); // } // else // { // tcFoot[i].Text = ""; // } //} for (int i = 1; i < listFootSum.Count; i++) { tcFoot.Add(new TableHeaderCell()); tcFoot[i].Text = listFootSum[i]; tcFoot[i].CssClass = "fontForRight"; tcFoot[i].Text = ChangeDataFormat(tcFoot[i].Text); } } } }
//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 = "调薪负责人"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].RowSpan = 2; tcHeader[8].Text = "调薪原因</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[9].Text = "原薪资"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].Text = "现薪资"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Text = "调薪金额"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Text = "调薪幅度(%)"; } }
protected void gvBody_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: string[] Name = gvBodyColumnName.Split(','); TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); for (int j = 0; j <= 3; 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[4].Attributes.Add("colspan", "2"); tcHeader[4].Text = Name[4].ToString(); tcHeader[4].Attributes.Add("bgcolor", "#F7F6F3"); tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("rowspan", "2"); tcHeader[5].Text = Name[5].ToString(); tcHeader[5].Attributes.Add("bgcolor", "#F7F6F3"); tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("colspan", "2"); tcHeader[6].Text = Name[6].ToString(); tcHeader[6].Attributes.Add("bgcolor", "#F7F6F3"); for (int j = 7; j <= 8; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Attributes.Add("rowspan", "2"); tcHeader[j].Text = Name[j].ToString(); tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); } for (int j = 9; j <= 10; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Text = Name[j].ToString(); tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); } for (int j = 9; j <= 10; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j + 2].Text = Name[j].ToString(); tcHeader[j + 2].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"); } } 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"); } int[] intSumQty = new int[8]; if (e.Row.RowType == DataControlRowType.Footer) { for (int i = 0; i < this.gvBody.Rows.Count; i++) { for (int j = 0; j < 8; j++) { intSumQty[j] += Convert.ToInt32(gvBody.Rows[i].Cells[j + 2].Text); } } for (int i = 0; i < this.gvBody.Rows.Count; i++) { for (int j = 0; j < 8; j++) { e.Row.Cells[j + 2].Text = intSumQty[j].ToString(); } } e.Row.Cells[0].Text = "合计"; } break; } GroupRows(gvBody, 0); GroupRows(gvBody, 10); }
protected void grdvw_List_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[0].Attributes.Add("rowspan", "3"); //跨Row tcHeader[0].Attributes.Add("colspan", "0"); //跨Column tcHeader[0].Text = "月分"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[1].Attributes.Add("rowspan", "0"); //跨Row tcHeader[1].Attributes.Add("colspan", "12"); //跨Column tcHeader[1].Text = "水质监测数据"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[2].Attributes.Add("rowspan", "0"); //跨Row tcHeader[2].Attributes.Add("colspan", "8"); //跨Column tcHeader[2].Text = "大气监测数据"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[3].Attributes.Add("rowspan", "2"); //跨Row tcHeader[3].Attributes.Add("colspan", "2"); //跨Column tcHeader[3].Text = "土壤、底质、煤样"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[4].Attributes.Add("rowspan", "2"); //跨Row tcHeader[4].Attributes.Add("colspan", "2"); //跨Column tcHeader[4].Text = "噪声监测"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[5].Attributes.Add("rowspan", "2"); //跨Row tcHeader[5].Attributes.Add("colspan", "2"); //跨Column tcHeader[5].Text = "桑叶氟化物"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[6].Attributes.Add("rowspan", "2"); //跨Row tcHeader[6].Attributes.Add("colspan", "2"); //跨Column tcHeader[6].Text = "合计</tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[7].Attributes.Add("rowspan", "0"); //跨Row tcHeader[7].Attributes.Add("colspan", "2"); //跨Column tcHeader[7].Text = "地表水"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("rowspan", "0"); //跨Row tcHeader[8].Attributes.Add("colspan", "2"); //跨Column tcHeader[8].Text = "污染源"; tcHeader[8].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("rowspan", "0"); //跨Row tcHeader[9].Attributes.Add("colspan", "2"); //跨Column tcHeader[9].Text = "大队"; tcHeader[9].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("rowspan", "0"); //跨Row tcHeader[10].Attributes.Add("colspan", "2"); //跨Column tcHeader[10].Text = "自送样"; tcHeader[10].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("bgcolor", "#008A23"); tcHeader[11].Attributes.Add("rowspan", "0"); //跨Row tcHeader[11].Attributes.Add("colspan", "2"); //跨Column tcHeader[11].Text = "三同时"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Text = "其他委托"; tcHeader[12].Attributes.Add("rowspan", "0"); //跨Row tcHeader[12].Attributes.Add("colspan", "2"); //跨Column tcHeader[12].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[13].Attributes.Add("rowspan", "0"); //跨Row tcHeader[13].Attributes.Add("colspan", "2"); //跨Column tcHeader[13].Text = "气常规"; tcHeader[13].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[14].Attributes.Add("rowspan", "0"); //跨Row tcHeader[14].Attributes.Add("colspan", "2"); //跨Column tcHeader[14].Text = "污染源"; tcHeader[14].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[15].Attributes.Add("rowspan", "0"); //跨Row tcHeader[15].Attributes.Add("colspan", "2"); //跨Column tcHeader[15].Text = "三同时"; tcHeader[15].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[16].Attributes.Add("rowspan", "0"); //跨Row tcHeader[16].Attributes.Add("colspan", "2"); //跨Column tcHeader[16].Text = "其他委托</tr><tr>"; tcHeader[16].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[17].Text = "样品数"; tcHeader[17].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[18].Text = "数据量"; tcHeader[18].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[19].Text = "样品数"; tcHeader[19].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[20].Text = "数据量"; tcHeader[20].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[21].Text = "样品数"; tcHeader[21].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[22].Text = "数据量"; tcHeader[22].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[23].Text = "样品数"; tcHeader[23].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[24].Text = "数据量"; tcHeader[24].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[25].Text = "样品数"; tcHeader[25].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[26].Text = "数据量"; tcHeader[26].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[27].Text = "样品数"; tcHeader[27].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[28].Text = "数据量"; tcHeader[28].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[29].Text = "样品数"; tcHeader[29].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[30].Text = "数据量"; tcHeader[30].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[31].Text = "样品数"; tcHeader[31].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[32].Text = "数据量"; tcHeader[32].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[33].Text = "样品数"; tcHeader[33].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[34].Text = "数据量"; tcHeader[34].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[35].Text = "样品数"; tcHeader[35].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[36].Text = "数据量"; tcHeader[36].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[37].Text = "样品数"; tcHeader[37].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[38].Text = "数据量"; tcHeader[38].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[39].Text = "样品数"; tcHeader[39].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[40].Text = "数据量"; tcHeader[40].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[41].Text = "样品数"; tcHeader[41].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[42].Text = "数据量"; tcHeader[42].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[43].Text = "样品数"; tcHeader[43].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[44].Text = "数据量</tr>"; tcHeader[44].Attributes.Add("bgcolor", "#005EBB"); ////数据行 内容自适应 不换行 //case DataControlRowType.DataRow: // TableCellCollection cells1 = e.Row.Cells; // for (int i = 0; i < cells1.Count; i++) // { // cells1[i].Wrap = false; //设置此项切记 不要设置前台GridView宽度 // } // e.Row.Cells[1].Visible = false;//绑定数据后,隐藏0列 } if (e.Row.RowType == DataControlRowType.DataRow) { //鼠标移动到每项时颜色交替效果 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='';"); e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#00ffee'"); } if (e.Row.RowType != DataControlRowType.Pager) { } }
protected void gvBodySum_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: string[] Name = gvBodySumColumnName.Split(','); TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); for (int j = 0; j <= 3; j++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Attributes.Add("rowspan", "2"); 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"); } } 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"); } double[] intSumQty = new double[2]; double DecimalDayQty = 0.0; if (e.Row.RowType == DataControlRowType.Footer) { for (int i = 0; i < this.gvBodySum.Rows.Count; i++) { for (int j = 0; j < 2; j++) { intSumQty[j] += Convert.ToInt32(gvBodySum.Rows[i].Cells[j + 1].Text); } } DecimalDayQty = Math.Round(intSumQty[1] / intSumQty[0], 1); for (int i = 0; i < this.gvBodySum.Rows.Count; i++) { for (int j = 0; j < 2; j++) { e.Row.Cells[j + 1].Text = intSumQty[j].ToString(); } } e.Row.Cells[0].Text = "合计"; e.Row.Cells[3].Text = DecimalDayQty.ToString(); } break; } }
protected void gvStuff_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].RowSpan = 2; cells[3].Text = "规格"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 2; cells[4].Text = "品牌"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 2; cells[5].Text = "单位"; cells.Add(new TableHeaderCell()); cells[6].ColumnSpan = 3; cells[6].Text = "材料数量"; cells.Add(new TableHeaderCell()); cells[7].ColumnSpan = 3; cells[7].Text = "材料价格"; cells.Add(new TableHeaderCell()); cells[8].ColumnSpan = 3; 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[11].Attributes.Add("title", " 实际数量 = 出库数量 – 退库数量 "); cells[11].CssClass = "tooltip"; 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 = "报量金额"; cells.Add(new TableHeaderCell()); cells[17].Text = "实际金额"; cells[17].Attributes.Add("title", " 实际数量 = 出库中成本归集于材料的资源金额 – 退库中成本归集于材料的资源金额 "); cells[17].CssClass = "tooltip"; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Text = "合计"; string[] array = (string[])this.ViewState["Total"]; e.Row.Cells[6].Text = array[0]; e.Row.Cells[6].Style.Add("text-align", "right"); e.Row.Cells[6].CssClass = "decimal_input"; e.Row.Cells[7].Text = array[1]; e.Row.Cells[7].Style.Add("text-align", "right"); e.Row.Cells[7].CssClass = "decimal_input"; e.Row.Cells[8].Text = array[2]; e.Row.Cells[8].Style.Add("text-align", "right"); e.Row.Cells[8].CssClass = "decimal_input"; e.Row.Cells[12].Text = array[3]; e.Row.Cells[12].Style.Add("text-align", "right"); e.Row.Cells[12].CssClass = "decimal_input"; e.Row.Cells[13].Text = array[4]; e.Row.Cells[13].Style.Add("text-align", "right"); e.Row.Cells[13].CssClass = "decimal_input"; e.Row.Cells[14].Text = array[5]; e.Row.Cells[14].Style.Add("text-align", "right"); e.Row.Cells[14].CssClass = "decimal_input"; } }
protected void gvProfit_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].RowSpan = 2; cells[3].Text = "开始日期"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 2; cells[4].Text = "结束日期"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 2; cells[5].Text = "项目状态"; cells.Add(new TableHeaderCell()); cells[6].RowSpan = 2; cells[6].Text = "项目申请人"; cells.Add(new TableHeaderCell()); cells[7].RowSpan = 2; cells[7].Text = "投标预算"; cells.Add(new TableHeaderCell()); cells[8].RowSpan = 2; cells[8].Text = "目标成本"; cells.Add(new TableHeaderCell()); cells[9].RowSpan = 2; cells[9].Text = "报量成本"; cells.Add(new TableHeaderCell()); cells[10].ColumnSpan = 6; cells[10].Text = "直接费用"; cells.Add(new TableHeaderCell()); cells[11].RowSpan = 2; cells[11].Text = "间接费用"; cells.Add(new TableHeaderCell()); cells[12].ColumnSpan = 2; cells[12].Text = "利润</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[13].Text = "直接材料费"; cells[13].Attributes.Add("title", " 直接材料费 = 出库物资金额 – 退库物资金额 "); cells[13].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[14].Text = "公司项目<br />人员费用"; cells[14].Attributes.Add("title", " 公司项目人员费用 = 合同类型中成本归集于人工的合同金额 "); cells[14].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[15].Text = "公司项目<br />机械设备费用"; cells[15].Attributes.Add("title", " 公司项目机械设备费用 = 合同类型中成本归集于机械的合同金额 "); cells[15].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[16].Text = "外包费用"; cells[16].Attributes.Add("title", " 外包费用 = 合同类型中成本归集于外包费用的合同金额 "); cells[16].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[17].Text = "其他"; cells[17].Attributes.Add("title", " 其他 = 合同类型中成本归集于其他的合同金额 "); cells[17].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[18].Text = "实际直接费用"; cells[18].Attributes.Add("title", " 实际直接费用 = 直接材料费 + 公司项目人员费用 + 公司项目机械设备费用 + 外包费用 + 其他 "); cells[18].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[19].Text = "目标利润"; cells[19].Attributes.Add("title", " 目标利润 = 投标预算金额 – 目标成本 "); cells[19].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[20].Text = "实际利润"; cells[20].Attributes.Add("title", " 实际利润 = 投标预算金额 – 实际直接成本 – 间接费用 "); cells[20].CssClass = "tooltip"; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Text = "合计"; string[] array = (string[])this.ViewState["Total"]; e.Row.Cells[7].Text = array[0]; e.Row.Cells[7].Style.Add("text-align", "right"); e.Row.Cells[7].CssClass = "decimal_input"; e.Row.Cells[8].Text = array[1]; e.Row.Cells[8].Style.Add("text-align", "right"); e.Row.Cells[8].CssClass = "decimal_input"; e.Row.Cells[9].Text = array[2]; e.Row.Cells[9].Style.Add("text-align", "right"); e.Row.Cells[9].CssClass = "decimal_input"; e.Row.Cells[10].Text = array[3]; e.Row.Cells[10].Style.Add("text-align", "right"); e.Row.Cells[10].CssClass = "decimal_input"; e.Row.Cells[11].Text = array[4]; e.Row.Cells[11].Style.Add("text-align", "right"); e.Row.Cells[11].CssClass = "decimal_input"; e.Row.Cells[12].Text = array[5]; e.Row.Cells[12].Style.Add("text-align", "right"); e.Row.Cells[12].CssClass = "decimal_input"; e.Row.Cells[13].Text = array[6]; e.Row.Cells[13].Style.Add("text-align", "right"); e.Row.Cells[13].CssClass = "decimal_input"; e.Row.Cells[14].Text = array[7]; e.Row.Cells[14].Style.Add("text-align", "right"); e.Row.Cells[14].CssClass = "decimal_input"; e.Row.Cells[15].Text = array[8]; e.Row.Cells[15].Style.Add("text-align", "right"); e.Row.Cells[15].CssClass = "decimal_input"; e.Row.Cells[16].Text = array[9]; e.Row.Cells[16].Style.Add("text-align", "right"); e.Row.Cells[16].CssClass = "decimal_input"; e.Row.Cells[17].Text = array[10]; e.Row.Cells[17].Style.Add("text-align", "right"); e.Row.Cells[17].CssClass = "decimal_input"; e.Row.Cells[18].Text = array[11]; e.Row.Cells[18].Style.Add("text-align", "right"); e.Row.Cells[18].CssClass = "decimal_input"; } }
protected void gvBody_RowDataBound(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 < 7; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Attributes.Add("rowspan", "3"); tcHeader[i].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i].Text = strHeader.Split(',')[i]; } DataTable title1 = MESComment.proDailyOutputSql.Getlevel1TitleList(ddlfactoryCd.SelectedItem.Value, ddlgarmentType.SelectedItem.Value, ddlWashType.SelectedItem.Value, txtDate.Text, ddlprocessCd.SelectedItem.Value, strContent, strTitle, MESConn); for (int i = 0; i < title1.Rows.Count; i++) { if (i != title1.Rows.Count - 1) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7].Attributes.Add("colspan", "" + title1.Rows[i]["N_NO"].ToString() + ""); tcHeader[i + 7].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 7].Text = title1.Rows[i]["RFNames1"].ToString(); } else { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7].Attributes.Add("colspan", "" + title1.Rows[i]["N_NO"].ToString() + ""); tcHeader[i + 7].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 7].Text = title1.Rows[i]["RFNames1"].ToString() + "</th></tr><tr>"; } } //second row DataTable title2 = MESComment.proDailyOutputSql.Getlevel2TitleList(ddlfactoryCd.SelectedItem.Value, ddlgarmentType.SelectedItem.Value, ddlWashType.SelectedItem.Value, txtDate.Text, ddlprocessCd.SelectedItem.Value, strContent, strTitle, MESConn); for (int i = 0; i < title2.Rows.Count; i++) { if (i != title2.Rows.Count - 1) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7 + title1.Rows.Count].Attributes.Add("colspan", "" + title2.Rows[i]["N_NO2"].ToString() + ""); tcHeader[i + 7 + title1.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 7 + title1.Rows.Count].Text = title2.Rows[i]["RFNames2"].ToString(); } else { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7 + title1.Rows.Count].Attributes.Add("colspan", "" + title2.Rows[i]["N_NO2"].ToString() + ""); tcHeader[i + 7 + title1.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); tcHeader[i + 7 + title1.Rows.Count].Text = title2.Rows[i]["RFNames2"].ToString() + "</th></tr><tr>"; } } DataTable title3 = MESComment.proDailyOutputSql.Getlevel3TitleList(ddlfactoryCd.SelectedItem.Value, ddlgarmentType.SelectedItem.Value, ddlWashType.SelectedItem.Value, txtDate.Text, ddlprocessCd.SelectedItem.Value, strContent, strTitle, MESConn); for (int i = 0; i < title3.Rows.Count; i++) { if (i != title3.Rows.Count - 1) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7 + title1.Rows.Count + title2.Rows.Count].Text = title3.Rows[i]["RFNames3"].ToString(); tcHeader[i + 7 + title1.Rows.Count + title2.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); } else { tcHeader.Add(new TableHeaderCell()); tcHeader[i + 7 + title1.Rows.Count + title2.Rows.Count].Text = title3.Rows[i]["RFNames3"].ToString() + "</th></tr><tr>"; tcHeader[i + 7 + title1.Rows.Count + title2.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); } } break; case DataControlRowType.DataRow: if (array == null) { array = new object[e.Row.Cells.Count]; } for (int col = 0; col < e.Row.Cells.Count; col++) { if (col < 7) { array[col] = " "; } array[5] = "Total :"; if (col >= 7) { if (array[col] == null) { array[col] = Int32.Parse(e.Row.Cells[col].Text.Equals("") ? "0" : e.Row.Cells[col].Text); } else { array[col] = Int32.Parse(e.Row.Cells[col].Text.Equals("") ? "0" : e.Row.Cells[col].Text) + Int32.Parse(array[col].ToString()); } } } break; case DataControlRowType.Footer: for (int col = 0; col < e.Row.Cells.Count; col++) { e.Row.Cells[col].Text = array[col].ToString(); e.Row.Cells[col].Attributes.Add("bgcolor", "#efefe7"); } break; } }
protected void gvDetail_RowDataBound(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: int leftoverC = -1; //LEFTOVER_C_1子字段的起始位置; int countC = 0; //LEFTOVER_C子字段数; string[] Column = new string[getalldatae.Columns.Count]; string[] ColumnC = { "裁片问题车间下数", "车间欠配套下数", "车间疵品半成品下数", "车间大疵", "印花下数" }; for (int i = 0; i < getalldatae.Columns.Count; i++) { Column[i] = getalldatae.Columns[i].ColumnName.ToString(); if (Column[i] == "LEFTOVER_C_1") { leftoverC = i; } if (Column[i].Contains("LEFTOVER_C")) { countC++; } } TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //First Row for (int i = 0; i < leftoverC; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Attributes.Add("rowspan", "2"); tcHeader[i].Text = Column[i]; tcHeader[i].Attributes.Add("bgcolor", "#F7F6F3"); } tcHeader.Add(new TableHeaderCell()); tcHeader[leftoverC].Attributes.Add("colspan", countC.ToString()); tcHeader[leftoverC].Text = "Grade C"; tcHeader[leftoverC].Attributes.Add("bgcolor", "#F7F6F3"); int j = leftoverC + 1; for (int i = leftoverC + countC; i < getalldatae.Columns.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Attributes.Add("rowspan", "2"); tcHeader[j].Text = Column[i]; tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); j++; } tcHeader[j - 1].Text += "</th></tr><tr>"; //换行; //Second Row for (int i = 0; i < countC; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[j].Text = ColumnC[i]; tcHeader[j].Attributes.Add("bgcolor", "#F7F6F3"); j++; } break; case DataControlRowType.DataRow: e.Row.Cells[5].Style.Add("word-break", "break-all"); break; case DataControlRowType.Footer: break; } finishProgress(); }
protected void grdvw_List_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[0].Attributes.Add("rowspan", "0"); //跨Row tcHeader[0].Attributes.Add("colspan", "0"); //跨Column tcHeader[0].Text = "月分"; tcHeader.Add(new TableHeaderCell()); tcHeader[1].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[1].Attributes.Add("rowspan", "0"); //跨Row tcHeader[1].Attributes.Add("colspan", "0"); //跨Column tcHeader[1].Text = "三同时验收(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[2].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[2].Attributes.Add("rowspan", "0"); //跨Row tcHeader[2].Attributes.Add("colspan", "0"); //跨Column tcHeader[2].Text = "自送样(自查)厂次"; tcHeader.Add(new TableHeaderCell()); tcHeader[3].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[3].Attributes.Add("rowspan", "0"); //跨Row tcHeader[3].Attributes.Add("colspan", "0"); //跨Column tcHeader[3].Text = "限期治理验收(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[4].Attributes.Add("rowspan", "0"); //跨Row tcHeader[4].Attributes.Add("colspan", "0"); //跨Column tcHeader[4].Text = "废水自动设备复测(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[5].Attributes.Add("rowspan", "0"); //跨Row tcHeader[5].Attributes.Add("colspan", "0"); //跨Column tcHeader[5].Text = "涉刑涉法(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[6].Attributes.Add("rowspan", "0"); //跨Row tcHeader[6].Attributes.Add("colspan", "0"); //跨Column tcHeader[6].Text = "体系认证监测(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].Attributes.Add("bgcolor", "#8E8E8E"); tcHeader[7].Attributes.Add("rowspan", "0"); //跨Row tcHeader[7].Attributes.Add("colspan", "0"); //跨Column tcHeader[7].Text = "环评监测(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].Attributes.Add("rowspan", "0"); //跨Row tcHeader[8].Attributes.Add("colspan", "0"); //跨Column tcHeader[8].Text = "治水办(厂次)"; tcHeader[8].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[9].Attributes.Add("rowspan", "0"); //跨Row tcHeader[9].Attributes.Add("colspan", "0"); //跨Column tcHeader[9].Text = "清洁生产(厂次)"; tcHeader[9].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[10].Attributes.Add("rowspan", "0"); //跨Row tcHeader[10].Attributes.Add("colspan", "0"); //跨Column tcHeader[10].Text = "生态系列监测(厂次)"; tcHeader[10].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[11].Attributes.Add("rowspan", "0"); //跨Row tcHeader[11].Attributes.Add("colspan", "0"); //跨Column tcHeader[11].Text = "执法检查(厂次)"; tcHeader[11].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[12].Attributes.Add("bgcolor", "#008A23"); tcHeader[12].Attributes.Add("rowspan", "0"); //跨Row tcHeader[12].Attributes.Add("colspan", "0"); //跨Column tcHeader[12].Text = "其他(厂次)"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].Text = "污水厂监督监测(厂次)"; tcHeader[13].Attributes.Add("rowspan", "0"); //跨Row tcHeader[13].Attributes.Add("colspan", "0"); //跨Column tcHeader[13].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[14].Attributes.Add("rowspan", "0"); //跨Row tcHeader[14].Attributes.Add("colspan", "0"); //跨Column tcHeader[14].Text = "废水重点源、重金属重点企业(厂次)"; tcHeader[14].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[15].Attributes.Add("rowspan", "0"); //跨Row tcHeader[15].Attributes.Add("colspan", "0"); //跨Column tcHeader[15].Text = "废气重点源(厂次)"; tcHeader[15].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[16].Attributes.Add("rowspan", "0"); //跨Row tcHeader[16].Attributes.Add("colspan", "0"); //跨Column tcHeader[16].Text = "废气自动设备比对监测(厂次)"; tcHeader[16].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[17].Attributes.Add("rowspan", "0"); //跨Row tcHeader[17].Attributes.Add("colspan", "0"); //跨Column tcHeader[17].Text = "废水自动设备比对监测(厂次)"; tcHeader[17].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[18].Text = "废水自动设备验收(厂次)"; tcHeader[18].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[19].Text = "减排 (水:厂次)"; tcHeader[19].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[20].Text = "减排 (气:厂次)"; tcHeader[20].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[21].Text = "调查监测(样品数)"; tcHeader[21].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[22].Text = "污染事故监测(样品数)"; tcHeader[22].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[23].Text = "信访监测(样品数)"; tcHeader[23].Attributes.Add("bgcolor", "#005EBB"); tcHeader.Add(new TableHeaderCell()); tcHeader[24].Text = "自动站 (样品数)</tr>"; tcHeader[24].Attributes.Add("bgcolor", "#005EBB"); ////数据行 内容自适应 不换行 //case DataControlRowType.DataRow: // TableCellCollection cells1 = e.Row.Cells; // for (int i = 0; i < cells1.Count; i++) // { // cells1[i].Wrap = false; //设置此项切记 不要设置前台GridView宽度 // } // e.Row.Cells[1].Visible = false;//绑定数据后,隐藏0列 } if (e.Row.RowType == DataControlRowType.DataRow) { //鼠标移动到每项时颜色交替效果 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='';"); e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#00ffee'"); //int id = e.Row.RowIndex + 1; //e.Row.Cells[0].Text = id.ToString(); ////手动添加详细和删除按钮 //TableCell tabcDetail = new TableCell(); //tabcDetail.Width = 60; //tabcDetail.Style.Add("text-align", "center"); //ImageButton ibtnDetail = new ImageButton(); //ibtnDetail.ImageUrl = "~/images/Detail.gif"; //ibtnDetail.CommandName = "Edit"; //tabcDetail.Controls.Add(ibtnDetail); //e.Row.Cells.Add(tabcDetail); //TableCell tabcDel = new TableCell(); //tabcDel.Width = 30; //tabcDel.Style.Add("text-align", "center"); //ImageButton ibtnDel = new ImageButton(); //ibtnDel.ImageUrl = "~/images/Delete.gif"; //ibtnDel.ID = "btn_delete"; //ibtnDel.CommandName = "Delete"; //ibtnDel.Attributes.Add("OnClick", "if(!confirm('确定删除该项吗?')) return false;"); ////if (Int16.Parse(Request.Cookies["Cookies"].Values["u_level"].ToString()) > 2 || Request.Cookies["Cookies"].Values["u_purview"].ToString().Substring(0, 1) == "0") ////{ //// ibtnDel.Enabled = false; ////} //if (Request.Cookies["Cookies"].Values["u_purview"].ToString().Substring(2, 1) == "1") //{ // tabcDel.Controls.Add(ibtnDel); // e.Row.Cells.Add(tabcDel); //} //else //{ // ibtnDel.Visible = false; //} } if (e.Row.RowType != DataControlRowType.Pager) { ////绑定数据后,隐藏4,5,6,7列 //e.Row.Cells[1].Visible = false; //e.Row.Cells[3].Visible = false; //e.Row.Cells[7].Visible = false; //e.Row.Cells[10].Visible = false; //e.Row.Cells[11].Visible = false; //e.Row.Cells[12].Visible = false; //e.Row.Cells[13].Visible = false; //e.Row.Cells[14].Visible = false; //e.Row.Cells[15].Visible = false; //e.Row.Cells[16].Visible = false; //e.Row.Cells[17].Visible = false; //e.Row.Cells[18].Visible = false; } }
/// <summary> /// 将指定的GridView的列标题行矩阵化,配合MatrixTable使用 /// </summary> /// <param name="gv"></param> private void GridViewMatric(GridView gv) { GridViewRow row = gv.HeaderRow; if (row == null) { return; } if (row.Cells.Count == 0) { return; } #region 将列中分隔符转为多行表头 //求出有几个组 int groups = 1; foreach (TableCell c in row.Cells) { groups = c.Text.Split('→').Length; if (groups > 1) { break; } } if (groups == 1) { return; } string[] columnname = new string[row.Cells.Count]; for (int i = 0; i < columnname.Length; i++) { if (row.Cells[i].Visible) { columnname[i] = row.Cells[i].Text; } else { columnname[i] = ""; } } TableCellCollection dtc = row.Cells; dtc.Clear(); for (int gi = 0; gi <= groups - 1; gi++) { string groupname = ""; for (int i = 0; i < columnname.Length; i++) { string s = columnname[i]; if (s.IndexOf('→') == -1) { if (s != "") { TableHeaderCell c = new TableHeaderCell(); c.Text = s; c.RowSpan = groups - gi; dtc.Add(c); columnname[i] = ""; } } else { if (s.Substring(0, s.IndexOf('→')) != groupname) { TableHeaderCell c = new TableHeaderCell(); c.Text = s.Substring(0, s.IndexOf('→')); dtc.Add(c); groupname = s.Substring(0, s.IndexOf('→')); columnname[i] = s.Substring(s.IndexOf('→') + 1); } else { if (dtc[dtc.Count - 1].ColumnSpan == 0) { dtc[dtc.Count - 1].ColumnSpan = 1; } dtc[dtc.Count - 1].ColumnSpan += 1; columnname[i] = s.Substring(s.IndexOf('→') + 1); } } } if (gi != groups - 1) { dtc[dtc.Count - 1].Text += "</th></tr><tr>"; } } #endregion }
protected void gvStuff_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].RowSpan = 2; cells[3].Text = "规格"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 2; cells[4].Text = "品牌"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 2; cells[5].Text = "型号"; cells.Add(new TableHeaderCell()); cells[6].ColumnSpan = 3; cells[6].Text = "目标成本"; cells.Add(new TableHeaderCell()); cells[7].ColumnSpan = 5; cells[7].Text = "在途成本"; cells.Add(new TableHeaderCell()); cells[8].ColumnSpan = 3; cells[8].Text = "实际成本"; cells.Add(new TableHeaderCell()); cells[9].ColumnSpan = 2; cells[9].Text = "盈亏"; cells.Add(new TableHeaderCell()); cells[10].ColumnSpan = 2; cells[10].Text = "结存"; cells.Add(new TableHeaderCell()); cells[11].ColumnSpan = 2; cells[11].Text = "需求、出库量</th></tr><tr class='header'>"; 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 = "采购价格"; cells.Add(new TableHeaderCell()); cells[17].Text = "采购金额累计"; cells.Add(new TableHeaderCell()); cells[18].Text = "入库数量累计"; cells.Add(new TableHeaderCell()); cells[19].Text = "入库金额累计"; cells.Add(new TableHeaderCell()); cells[20].Text = "实际数量"; cells[20].Attributes.Add("title", " 实际数量 = 出库数量 – 退库数量 "); cells[20].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[21].Text = "实际价格"; cells[21].Attributes.Add("title", " 实际价格 = 编制采购单时的价格 "); cells[21].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[22].Text = "实际金额"; cells[22].Attributes.Add("title", " 实际数量 = 出库中成本归集于材料的物资金额 – 退库中成本归集于材料的物资金额 "); cells[22].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[23].Text = "数量"; cells[23].Attributes.Add("title", " 数量 = 目标数量 – 采购数量 "); cells[23].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[24].Text = "金额"; cells[24].Attributes.Add("title", " 金额 = 目标金额 – 采购金额 "); cells[24].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[25].Text = "数量"; cells[25].Attributes.Add("title", " 数量 = 采购数量 – 出库数量 "); cells[25].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[26].Text = "金额"; cells[26].Attributes.Add("title", " 金额 = 采购金额 – 出库金额 "); cells[26].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[27].Text = "已提需求量"; //cells[27].Attributes.Add("title", " 金额 = 采购金额 – 出库金额 "); cells[27].CssClass = "tooltip"; cells.Add(new TableHeaderCell()); cells[28].Text = "已出库量"; //cells[28].Attributes.Add("title", " 金额 = 采购金额 – 出库金额 "); cells[28].CssClass = "tooltip"; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Text = "合计"; string[] array = (string[])this.ViewState["Total"]; e.Row.Cells[6].Text = array[0]; e.Row.Cells[6].Style.Add("text-align", "right"); e.Row.Cells[6].CssClass = "decimal_input"; e.Row.Cells[8].Text = array[1]; e.Row.Cells[8].Style.Add("text-align", "right"); e.Row.Cells[8].CssClass = "decimal_input"; e.Row.Cells[9].Text = array[2]; e.Row.Cells[9].Style.Add("text-align", "right"); e.Row.Cells[9].CssClass = "decimal_input"; e.Row.Cells[11].Text = array[3]; e.Row.Cells[11].Style.Add("text-align", "right"); e.Row.Cells[11].CssClass = "decimal_input"; e.Row.Cells[12].Text = array[4]; e.Row.Cells[12].Style.Add("text-align", "right"); e.Row.Cells[12].CssClass = "decimal_input"; e.Row.Cells[13].Text = array[5]; e.Row.Cells[13].Style.Add("text-align", "right"); e.Row.Cells[13].CssClass = "decimal_input"; e.Row.Cells[14].Text = array[6]; e.Row.Cells[14].Style.Add("text-align", "right"); e.Row.Cells[14].CssClass = "decimal_input"; e.Row.Cells[16].Text = array[7]; e.Row.Cells[16].Style.Add("text-align", "right"); e.Row.Cells[16].CssClass = "decimal_input"; e.Row.Cells[17].Text = array[8]; e.Row.Cells[17].Style.Add("text-align", "right"); e.Row.Cells[17].CssClass = "decimal_input"; e.Row.Cells[18].Text = array[9]; e.Row.Cells[18].Style.Add("text-align", "right"); e.Row.Cells[18].CssClass = "decimal_input"; e.Row.Cells[19].Text = array[10]; e.Row.Cells[19].Style.Add("text-align", "right"); e.Row.Cells[19].CssClass = "decimal_input"; e.Row.Cells[20].Text = array[11]; e.Row.Cells[20].Style.Add("text-align", "right"); e.Row.Cells[20].CssClass = "decimal_input"; e.Row.Cells[21].Text = array[12]; e.Row.Cells[21].Style.Add("text-align", "right"); e.Row.Cells[21].CssClass = "decimal_input"; e.Row.Cells[22].Text = array[13]; e.Row.Cells[22].Style.Add("text-align", "right"); e.Row.Cells[22].CssClass = "decimal_input"; } }
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 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].RowSpan = 3; tcl.Add(new TableHeaderCell()); tcl[1].Text = "单位"; tcl[1].Wrap = false; tcl[1].RowSpan = 3; OracleAccess access = new OracleAccess(); string strSql = "select a.* from ZJ_CERTIFICATE_LEVEL a " + "inner join ZJ_CERTIFICATE c on a.CERTIFICATE_ID=c.CERTIFICATE_ID " + " order by c.CERTIFICATE_ID,a.ORDER_INDEX"; DataTable dtLevel = access.RunSqlDataSet(strSql).Tables[0]; strSql = "select * from ZJ_CERTIFICATE order by CERTIFICATE_ID"; DataTable dt = access.RunSqlDataSet(strSql).Tables[0]; tcl.Add(new TableHeaderCell()); tcl[2].Text = "证书名称</th></tr>"; tcl[2].Wrap = false; tcl[2].ColumnSpan = dtLevel.Rows.Count + 1; tcl.Add(new TableHeaderCell()); tcl[3].Text = "合计"; tcl[3].Wrap = false; tcl[3].RowSpan = 2; for (int i = 0; i < dt.Rows.Count; i++) { tcl.Add(new TableHeaderCell()); if (i + 1 == dt.Rows.Count) { tcl[4 + i].Text = dt.Rows[i]["CERTIFICATE_NAME"] + "</th></tr>"; } else { tcl[4 + i].Text = dt.Rows[i]["CERTIFICATE_NAME"].ToString(); } tcl[4 + i].Wrap = false; DataRow[] drs = dtLevel.Select("CERTIFICATE_ID=" + dt.Rows[i]["CERTIFICATE_ID"]); tcl[4 + i].ColumnSpan = drs.Length; } int index = 3 + dt.Rows.Count + 1; for (int i = 0; i < dtLevel.Rows.Count; i++) { tcl.Add(new TableHeaderCell()); if (i + 1 == dtLevel.Rows.Count) { tcl[index + i].Text = dtLevel.Rows[i]["CERTIFICATE_Level_NAME"] + "</th></tr>"; } else { tcl[index + i].Text = dtLevel.Rows[i]["CERTIFICATE_Level_NAME"].ToString(); } tcl[index + i].Wrap = false; } } 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) { string typeType = ""; if (ddlLBZL.SelectedValue != "-1") { typeType = ddlLBZL.SelectedValue; } string typeID = ""; if (ddlLB.SelectedValue != "0") { typeID = ddlLB.SelectedValue; } DataTable dt = ckrbService.SELECT_MSMaterial(typeType, typeID); DataTable dti = ckrbService.SELECT_MSRptItem(); DataTable dttype = ckrbService.SELECT_MSType(typeType, typeID); if (dt.Rows.Count > 50) { switch (e.Row.RowType) { case DataControlRowType.Header: //行是标题行 TableCellCollection personHeader = e.Row.Cells; //标题行的单元格集合 personHeader.Clear(); //清空 personHeader.Add(new TableHeaderCell()); personHeader[0].Text = "日期"; int s = 0; if (dttype.Rows.Count > 0) { for (int i = 0; i < dttype.Rows.Count; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = dttype.Rows[i]["typeName"].ToString(); s = s + 1; } } if (rbl1.SelectedValue == "1") { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = "小计"; s = s + 1; } if (dti.Rows.Count > 0) { for (int i = 0; i < dti.Rows.Count; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = dti.Rows[i]["ItemName"].ToString(); s = s + 1; } } break; } } else { switch (e.Row.RowType) { case DataControlRowType.Header: //行是标题行 TableCellCollection personHeader = e.Row.Cells; //标题行的单元格集合 personHeader.Clear(); //清空 personHeader.Add(new TableHeaderCell()); personHeader[0].Text = "日期"; int s = 0; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = dt.Rows[i]["mtName"].ToString(); s = s + 1; } } if (rbl1.SelectedValue == "1") { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = "小计"; s = s + 1; } if (dti.Rows.Count > 0) { for (int i = 0; i < dti.Rows.Count; i++) { personHeader.Add(new TableHeaderCell()); personHeader[s + 1].Text = dti.Rows[i]["ItemName"].ToString(); s = s + 1; } } break; } } }
protected void gvwRefuelApply_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].ColumnSpan = 10; cells[1].Text = "加油概况"; cells.Add(new TableHeaderCell()); cells[2].ColumnSpan = 3; cells[2].Text = "审核栏</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[3].RowSpan = 1; cells[3].Text = "船机编号"; cells.Add(new TableHeaderCell()); cells[4].RowSpan = 1; cells[4].Text = "开工至今该项目<br />该船累计加油数量(吨)"; cells.Add(new TableHeaderCell()); cells[5].RowSpan = 1; cells[5].Text = "现有库存量(吨)"; cells.Add(new TableHeaderCell()); cells[6].RowSpan = 1; cells[6].Text = "本次申请数量(吨)"; cells.Add(new TableHeaderCell()); cells[7].RowSpan = 1; cells[7].Text = "本项目<br />该船预计完成工程量(m3)"; cells.Add(new TableHeaderCell()); cells[8].RowSpan = 1; cells[8].Text = "开工至今该船累计完成<br />该项目工程量(m3)/累计施工时间"; cells.Add(new TableHeaderCell()); cells[9].RowSpan = 1; cells[9].Text = "挖深(m)"; cells.Add(new TableHeaderCell()); cells[10].RowSpan = 1; cells[10].Text = "申请加油地点"; cells.Add(new TableHeaderCell()); cells[11].RowSpan = 1; cells[11].Text = "申请加油时间"; cells.Add(new TableHeaderCell()); cells[12].RowSpan = 1; cells[12].Text = "是否委托采购"; cells.Add(new TableHeaderCell()); cells[13].RowSpan = 1; cells[13].Text = "申请船主"; cells.Add(new TableHeaderCell()); cells[14].RowSpan = 1; cells[14].Text = "本次批准加油数量<br />(吨,船机部复核)"; cells.Add(new TableHeaderCell()); cells[15].RowSpan = 1; cells[15].Text = "船机部审核人员"; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Style.Add("text-align", "right"); e.Row.Cells[1].Text = "合计"; e.Row.Cells[2].Style.Add("text-align", "right"); e.Row.Cells[2].Text = this.total[0]; e.Row.Cells[3].Style.Add("text-align", "right"); e.Row.Cells[3].Text = this.total[1]; e.Row.Cells[4].Style.Add("text-align", "right"); e.Row.Cells[4].Text = this.total[2]; e.Row.Cells[5].Style.Add("text-align", "right"); e.Row.Cells[5].Text = this.total[3]; e.Row.Cells[6].Style.Add("text-align", "right"); e.Row.Cells[6].Text = this.total[4]; e.Row.Cells[7].Style.Add("text-align", "right"); e.Row.Cells[7].Text = this.total[5]; e.Row.Cells[12].Style.Add("text-align", "right"); e.Row.Cells[12].Text = this.total[6]; } }
protected void gvwOilWear_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 = "入库"; cells.Add(new TableHeaderCell()); cells[4].ColumnSpan = 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].RowSpan = 2; cells[8].Text = "仓管员"; cells.Add(new TableHeaderCell()); cells[9].RowSpan = 2; cells[9].Text = "签收人</th></tr><tr class='header'>"; cells.Add(new TableHeaderCell()); cells[10].RowSpan = 1; cells[10].Text = "入库日期"; cells.Add(new TableHeaderCell()); cells[11].RowSpan = 1; cells[11].Text = "单价(元/L)"; cells.Add(new TableHeaderCell()); cells[12].RowSpan = 1; cells[12].Text = "数量(L)"; cells.Add(new TableHeaderCell()); cells[13].RowSpan = 1; cells[13].Text = "金额(元)"; cells.Add(new TableHeaderCell()); cells[14].RowSpan = 1; cells[14].Text = "数量(L) "; cells.Add(new TableHeaderCell()); cells[15].RowSpan = 1; cells[15].Text = "金额(元)"; cells.Add(new TableHeaderCell()); cells[16].RowSpan = 1; cells[16].Text = "数量(L) "; cells.Add(new TableHeaderCell()); cells[17].RowSpan = 1; cells[17].Text = "金额(元)"; cells.Add(new TableHeaderCell()); cells[18].RowSpan = 1; cells[18].Text = "数量(L) "; cells.Add(new TableHeaderCell()); cells[19].RowSpan = 1; cells[19].Text = "金额(元)"; cells.Add(new TableHeaderCell()); cells[20].RowSpan = 1; cells[20].Text = "数量(L) "; cells.Add(new TableHeaderCell()); cells[21].RowSpan = 1; cells[21].Text = "金额(元)"; } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[1].Style.Add("text-align", "right"); e.Row.Cells[1].Text = "合计"; e.Row.Cells[5].Style.Add("text-align", "right"); e.Row.Cells[5].Text = this.total[0]; e.Row.Cells[6].Style.Add("text-align", "right"); e.Row.Cells[6].Text = this.total[1]; e.Row.Cells[7].Style.Add("text-align", "right"); e.Row.Cells[7].Text = this.total[2]; e.Row.Cells[8].Style.Add("text-align", "right"); e.Row.Cells[8].Text = this.total[3]; e.Row.Cells[9].Style.Add("text-align", "right"); e.Row.Cells[9].Text = this.total[4]; e.Row.Cells[10].Style.Add("text-align", "right"); e.Row.Cells[10].Text = this.total[5]; e.Row.Cells[11].Style.Add("text-align", "right"); e.Row.Cells[11].Text = this.total[6]; e.Row.Cells[12].Style.Add("text-align", "right"); e.Row.Cells[12].Text = this.total[7]; e.Row.Cells[13].Style.Add("text-align", "right"); e.Row.Cells[13].Text = this.total[8]; e.Row.Cells[14].Style.Add("text-align", "right"); e.Row.Cells[14].Text = this.total[9]; e.Row.Cells[15].Style.Add("text-align", "right"); e.Row.Cells[15].Text = this.total[10]; } }
protected void gvBody_RowDataBound(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 < strHeader.Split(',').Length; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Attributes.Add("rowspan", "2"); tcHeader[i].Text = strHeader.Split(',')[i]; tcHeader[i].Attributes.Add("bgcolor", "#efefe7"); } for (int i = 0; i < dtTitle.Rows.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + strHeader.Split(',').Length].Text = dtTitle.Rows[i]["SIZE_CD"].ToString(); tcHeader[i + strHeader.Split(',').Length].Attributes.Add("bgcolor", "#efefe7"); } for (int i = 0; i < strHeader1.Split(',').Length; i++) { tcHeader.Add(new TableHeaderCell()); if (i == 1) { tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count].Attributes.Add("colspan", "3"); } if (i != 0 && i != 1) { tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count].Attributes.Add("rowspan", "2"); } tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count].Text = strHeader1.Split(',')[i]; tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); } //second row int colTotal = 0; for (int i = 0; i < dtTitle.Rows.Count; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length].Text = dtTitle.Rows[i]["ORDER_QTY"].ToString(); tcHeader[i + strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length].Attributes.Add("bgcolor", "#efefe7"); colTotal += int.Parse(dtTitle.Rows[i]["ORDER_QTY"].ToString()); } tcHeader.Add(new TableHeaderCell()); tcHeader[strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length + dtTitle.Rows.Count].Text = colTotal.ToString(); tcHeader[strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length + dtTitle.Rows.Count].Attributes.Add("bgcolor", "#efefe7"); for (int i = 0; i < strHeader2.Split(',').Length; i++) { tcHeader.Add(new TableHeaderCell()); tcHeader[strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length + dtTitle.Rows.Count + 1 + i].Text = strHeader2.Split(',')[i]; tcHeader[strHeader.Split(',').Length + dtTitle.Rows.Count + strHeader1.Split(',').Length + dtTitle.Rows.Count + 1 + i].Attributes.Add("bgcolor", "#efefe7"); } break; case DataControlRowType.DataRow: TotalValue[0] += int.Parse(e.Row.Cells[6].Text == " " ? "0" : e.Row.Cells[6].Text); TotalValue[1] += int.Parse(e.Row.Cells[7].Text == " " ? "0" : e.Row.Cells[7].Text); for (int i = 0; i < dtTitle.Rows.Count; i++) { TotalValue[i + 2] += int.Parse(e.Row.Cells[8 + i].Text == " " ? "0" : e.Row.Cells[8 + i].Text) * int.Parse(e.Row.Cells[7].Text == " " ? "0" : e.Row.Cells[7].Text); } TotalValue[dtTitle.Rows.Count + 2] += int.Parse(e.Row.Cells[8 + dtTitle.Rows.Count].Text == " " ? "0" : e.Row.Cells[8 + dtTitle.Rows.Count].Text) * int.Parse(e.Row.Cells[7].Text == " " ? "0" : e.Row.Cells[7].Text); TotalValue[dtTitle.Rows.Count + 3] += float.Parse(e.Row.Cells[8 + dtTitle.Rows.Count + 5].Text == " " ? "0" : e.Row.Cells[8 + dtTitle.Rows.Count + 5].Text); break; case DataControlRowType.Footer: TableCellCollection tcFooter = e.Row.Cells; tcFooter.Clear(); tcFooter.Add(new TableHeaderCell()); int cols = 17 + dtTitle.Rows.Count; for (int i = 0; i < cols; i++) { tcFooter.Add(new TableHeaderCell()); tcFooter[i].Attributes.Add("align", "left"); if (i == 0) { tcFooter[i].Text = "Total"; } if (i >= 6 && i < 6 + dtTitle.Rows.Count + 3) { tcFooter[i].Text = TotalValue[i - 6].ToString(); } if (i == 7 + dtTitle.Rows.Count + 6) { tcFooter[i].Text = TotalValue[dtTitle.Rows.Count + 3].ToString("f2"); } } break; } }
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); TableHeaderCell cell = new TableHeaderCell(); cell.Text = "序号"; cell.RowSpan = 2; cell.BackColor = Color.FromArgb(184, 204, 228); cell.Width = 60; tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "姓名"; cell.BackColor = Color.FromArgb(184, 204, 228); cell.RowSpan = 2; cell.Width = 90; tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "班级"; cell.BackColor = Color.FromArgb(184, 204, 228); cell.RowSpan = 2; cell.Width = 120; tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "老师"; cell.BackColor = Color.FromArgb(151, 72, 7); cell.ColumnSpan = 6; tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "班长</th></tr><tr>"; cell.BackColor = Color.FromArgb(49, 132, 155); cell.ColumnSpan = 6; tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "旷课"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "迟到"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "早退"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "事假"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "病假"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "详细记录"; cell.BackColor = Color.FromArgb(229, 224, 236); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "旷课"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "迟到"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "早退"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "事假"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "病假"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); cell = new TableHeaderCell(); cell.Text = "详细记录"; cell.BackColor = Color.FromArgb(219, 229, 241); tcHeader.Add(cell); } }
//合并表头 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].RowSpan = 2; tcHeader[3].Text = "客房类型"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].RowSpan = 2; tcHeader[4].Text = "床位数量"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].ColumnSpan = 5; tcHeader[5].Text = "客房配置"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].RowSpan = 2; tcHeader[6].Text = "每晚价格"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].RowSpan = 2; tcHeader[7].Text = "客房总量"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].RowSpan = 2; tcHeader[8].Text = "备注"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].RowSpan = 2; tcHeader[9].Text = "空房数量"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].RowSpan = 2; tcHeader[10].ColumnSpan = 2; tcHeader[10].Text = "操作</th></tr><tr>"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].Text = "空调"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].Text = "电视机"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].Text = "电吹风"; tcHeader.Add(new TableHeaderCell()); tcHeader[14].Text = "电话"; tcHeader.Add(new TableHeaderCell()); tcHeader[15].Text = "WIFI"; //背表头颜色 for (int i = 0; i < 16; i++) { tcHeader[i].BackColor = System.Drawing.Color.Blue; tcHeader[i].ForeColor = System.Drawing.Color.White; } } }
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].RowSpan = 2; tcl.Add(new TableHeaderCell()); tcl[1].Text = "单位"; tcl[1].Wrap = false; tcl[1].RowSpan = 2; tcl.Add(new TableHeaderCell()); tcl[2].Text = "举办单位"; tcl[2].Wrap = false; tcl[2].ColumnSpan = 5; tcl.Add(new TableHeaderCell()); tcl[3].Text = "竞赛类别</th></tr>"; tcl[3].Wrap = false; tcl[3].ColumnSpan = 5; tcl.Add(new TableHeaderCell()); tcl[4].Text = "合计"; tcl[4].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[5].Text = "全国"; tcl[5].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[6].Text = "铁道部"; tcl[6].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[7].Text = "铁道局"; tcl[7].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[8].Text = "站段"; tcl[8].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[9].Text = "合计"; tcl[9].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[10].Text = "单项"; tcl[10].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[11].Text = "全能"; tcl[11].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[12].Text = "团体"; tcl[12].Wrap = false; tcl.Add(new TableHeaderCell()); tcl[13].Text = "其他"; tcl[13].Wrap = false; } 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 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; } }
//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].ColumnSpan = 2; tcHeader[3].Text = "一月"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].ColumnSpan = 2; tcHeader[4].Text = "二月"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].ColumnSpan = 2; tcHeader[5].Text = "三月"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].ColumnSpan = 2; tcHeader[6].Text = "四月"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].ColumnSpan = 2; tcHeader[7].Text = "五月"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].ColumnSpan = 2; tcHeader[8].Text = "六月"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].ColumnSpan = 2; tcHeader[9].Text = "七月"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].ColumnSpan = 2; tcHeader[10].Text = "八月"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].ColumnSpan = 2; tcHeader[11].Text = "九月"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].ColumnSpan = 2; tcHeader[12].Text = "十月"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].ColumnSpan = 2; tcHeader[13].Text = "十一月"; tcHeader.Add(new TableHeaderCell()); tcHeader[14].ColumnSpan = 2; tcHeader[14].Text = "十二月</th></tr><tr>"; //第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[15].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[16].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[17].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[18].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[19].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[20].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[21].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[22].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[23].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[24].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[25].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[26].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[27].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[28].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[29].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[30].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[31].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[32].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[33].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[34].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[35].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[36].Text = "停机率"; tcHeader.Add(new TableHeaderCell()); tcHeader[37].Text = "维修率"; tcHeader.Add(new TableHeaderCell()); tcHeader[38].Text = "停机率</th></tr><tr>"; } }
//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].ColumnSpan = 7; tcHeader[3].Text = "一月"; tcHeader.Add(new TableHeaderCell()); tcHeader[4].ColumnSpan = 7; tcHeader[4].Text = "二月"; tcHeader.Add(new TableHeaderCell()); tcHeader[5].ColumnSpan = 7; tcHeader[5].Text = "三月"; tcHeader.Add(new TableHeaderCell()); tcHeader[6].ColumnSpan = 7; tcHeader[6].Text = "四月"; tcHeader.Add(new TableHeaderCell()); tcHeader[7].ColumnSpan = 7; tcHeader[7].Text = "五月"; tcHeader.Add(new TableHeaderCell()); tcHeader[8].ColumnSpan = 7; tcHeader[8].Text = "六月"; tcHeader.Add(new TableHeaderCell()); tcHeader[9].ColumnSpan = 7; tcHeader[9].Text = "七月"; tcHeader.Add(new TableHeaderCell()); tcHeader[10].ColumnSpan = 7; tcHeader[10].Text = "八月"; tcHeader.Add(new TableHeaderCell()); tcHeader[11].ColumnSpan = 7; tcHeader[11].Text = "九月"; tcHeader.Add(new TableHeaderCell()); tcHeader[12].ColumnSpan = 7; tcHeader[12].Text = "十月"; tcHeader.Add(new TableHeaderCell()); tcHeader[13].ColumnSpan = 7; tcHeader[13].Text = "十一月"; tcHeader.Add(new TableHeaderCell()); tcHeader[14].ColumnSpan = 7; tcHeader[14].Text = "十二月</th></tr><tr>"; //第二行表头 int i; for (i = 15; i <= 98;) { tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "试用期内"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "三至六月"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "六月至一年"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "一至二年"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "二至五年"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "五至十年"; i += 1; tcHeader.Add(new TableHeaderCell()); tcHeader[i].Text = "十年以上"; i += 1; } } }
private void AddCells(TableCellCollection cells, FmriRequest req) { TableCell c; c = new TableCell(); c.Text = req.ImageName; cells.Add(c); c = new TableCell(); c.Text = "" + req.X1 + "-" + req.X2; cells.Add(c); c = new TableCell(); c.Text = "" + req.Y1 + "-" + req.Y2; cells.Add(c); c = new TableCell(); c.Text = "" + req.Z1 + "-" + req.Z2; cells.Add(c); c = new TableCell(); c.Text = Convert.ToString(req.Threshold); cells.Add(c); c = new TableCell(); c.Text = "" + req.T1 + "-" + req.T2; cells.Add(c); c = new TableCell(); c.Text = "" + req.CS1 + "-" + req.CS2; cells.Add(c); c = new TableCell(); c.Text = req.IPAddress; cells.Add(c); c = new TableCell(); c.Text = Convert.ToString(req.TimeSubmitted); cells.Add(c); }