public void QueryASPxGridView() { GridView1.DataSource = null; GridView1.DataBind(); Baojia_Report_sql BaojiaSQLHelp = new Baojia_Report_sql(); DataTable dt = BaojiaSQLHelp.Get_Baojia_history_update_data(this.txtBaojia_no.Text.ToString(), this.txtCustomer_name.Text.ToString(), this.ddl_update_user.SelectedValue.ToString() ); this.GridView1.DataSource = dt; GridView1.DataBind(); //合并单元格 int[] cols = { 0, 1, 2, 3, 4, 5, 9, 10, 11 }; MergGridRow.MergeRow(GridView1, cols); int rowIndex = 1; for (int j = 0; j < GridView1.Rows.Count; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { GridView1.Rows[j].Cells[0].Text = rowIndex.ToString(); HyperLink link = new HyperLink(); link.ID = "link" + rowIndex.ToString(); link.NavigateUrl = "Baojia.aspx?requestid=" + Server.HtmlDecode(GridView1.Rows[j].Cells[11].Text).Trim() + "&update=1"; link.Text = GridView1.Rows[j].Cells[1].Text; link.Target = "_blank"; GridView1.Rows[j].Cells[1].Controls.Add(link); rowIndex++; } } }
public void QueryASPxGridView() { GridView1.DataSource = null; GridView1.DataBind(); Baojia_Report_sql BaojiaSQLHelp = new Baojia_Report_sql(); DataTable dt = BaojiaSQLHelp.Get_Baojia_Task_Query_Data(this.ddlyear.SelectedValue.ToString(), this.txt_startdate.Text, this.txt_enddate.Text, this.ddlBaojiaStatus.SelectedValue.ToString(), this.ddlsign_status.SelectedValue.ToString(), this.txt_date.Value, this.ddlzzgc.SelectedValue.ToString(), this.ddl_depart.SelectedValue.ToString(), this.ddl_update_user.SelectedValue.ToString(), this.ddl_ISDelay.SelectedValue.ToString() ); this.GridView1.DataSource = dt; GridView1.DataBind(); int[] cols = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 17, 18 }; MergGridRow.MergeRow(GridView1, cols); //获取最新的requestid int visbleRow = 0; for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { visbleRow = j; } else { GridView1.Rows[visbleRow].Cells[18].Text = GridView1.Rows[j].Cells[18].Text; } } int rowIndex = 1; for (int j = 0; j < GridView1.Rows.Count; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { GridView1.Rows[j].Cells[0].Text = rowIndex.ToString(); HyperLink link = new HyperLink(); link.ID = "link" + rowIndex.ToString(); link.NavigateUrl = "Baojia.aspx?requestid=" + Server.HtmlDecode(GridView1.Rows[j].Cells[18].Text).Trim(); link.Text = GridView1.Rows[j].Cells[1].Text; link.Target = "_blank"; GridView1.Rows[j].Cells[1].Controls.Add(link); rowIndex++; } } }
public void QueryASPxGridView() { GridView1.DataSource = null; GridView1.DataBind(); Baojia_Report_sql BaojiaSQLHelp = new Baojia_Report_sql(); DataTable dt = BaojiaSQLHelp.Get_Baojia_Process_Query_Data(this.txtBaojia_no.Text.ToString(), this.txtCustomer_name.Text.ToString(), this.txtRenyuan.Text.ToString(), this.ddlBaojia_status.SelectedValue.ToString()); this.GridView1.DataSource = dt; GridView1.DataBind(); int[] cols = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18 }; MergGridRow.MergeRow(GridView1, cols); //获取最新的requestid int visbleRow = 0; for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { visbleRow = j; } else { GridView1.Rows[visbleRow].Cells[16].Text = GridView1.Rows[j].Cells[16].Text; } } int rowIndex = 1; for (int j = 0; j < GridView1.Rows.Count; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { GridView1.Rows[j].Cells[0].Text = rowIndex.ToString(); HyperLink link = new HyperLink(); link.ID = "link" + rowIndex.ToString(); link.NavigateUrl = "Baojia.aspx?requestid=" + Server.HtmlDecode(GridView1.Rows[j].Cells[16].Text).Trim(); link.Text = GridView1.Rows[j].Cells[1].Text; link.Target = "_blank"; GridView1.Rows[j].Cells[1].Controls.Add(link); rowIndex++; } } }
public void BindGridviewDTL(string condition, string project_level, string value) { Baojia_Report_sql BaojiaSQLHelp = new Baojia_Report_sql(); DataTable ds = BaojiaSQLHelp.Get_Baojia_FenXi_ZD_Project_dtl(condition, project_level, value); this.GridView1.DataSource = ds; GridView1.DataBind(); GridView1.Rows[GridView1.Rows.Count - 1].Cells[17].Text = ""; GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].Text = ""; GridView1.Rows[GridView1.Rows.Count - 1].Cells[3].Text = ""; GridView1.Rows[GridView1.Rows.Count - 1].BackColor = System.Drawing.Color.LightYellow; /* * int[] cols = { 0, 1, 2, 3, 4, 5, 6, 15, 17, 18, 19 }; * * MergGridRow.MergeRow(GridView1, cols); * int visbleRow = 0; * for (int j = 0; j <= GridView1.Rows.Count - 1; j++) * { * if (GridView1.Rows[j].Cells[0].Visible == true) * { * visbleRow = j; * } * else * { * GridView1.Rows[visbleRow].Cells[19].Text = GridView1.Rows[j].Cells[19].Text; * } * * } */ int[] cols = { 0, 1, 2, 3, 4, 5, 6, 17, 18, 19 }; MergGridRow.MergeRow(GridView1, cols); int[] cols2 = { 0, 15 }; MergGridRow.MergeRow(GridView1, cols2); int visbleRow = 0; for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { visbleRow = j; } else { GridView1.Rows[visbleRow].Cells[19].Text = GridView1.Rows[j].Cells[19].Text; } } int rowIndex = 1; for (int j = 0; j < GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { GridView1.Rows[j].Cells[0].Text = rowIndex.ToString(); HyperLink link = new HyperLink(); link.ID = "link" + rowIndex.ToString(); link.NavigateUrl = "Baojia.aspx?requestid=" + Server.HtmlDecode(GridView1.Rows[j].Cells[20].Text).Trim(); link.Text = GridView1.Rows[j].Cells[1].Text; link.Target = "_blank"; GridView1.Rows[j].Cells[1].Controls.Add(link); rowIndex++; } GridView1.Rows[j].Cells[17].Attributes.Add("onclick", "OpenMsg(this.firstElementChild,'" + condition + "');"); } }
///<summary> /// 查询按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { System.Text.StringBuilder sbSQL = new System.Text.StringBuilder(); sbSQL.Append("exec [Baojia_Query] "); sbSQL.Append("'" + this.txtBaojia_no.Text.Trim() + "',"); sbSQL.Append("'" + this.ddlTurns.SelectedValue + "',"); sbSQL.Append("'" + this.txtCustomer_name.Text + "',"); sbSQL.Append("'" + this.txtCustomer_name.Text + "',"); sbSQL.Append("'" + this.txtCustomer_project.Text + "',"); sbSQL.Append("'" + this.ddlProject_size.SelectedValue + "',"); sbSQL.Append("'" + this.ddlProject_size.SelectedItem.Text + "',"); sbSQL.Append("'" + this.ddlProject_level.SelectedItem.Text + "',"); sbSQL.Append("'" + this.ddlbaojia_status.SelectedItem.Text + "',"); sbSQL.Append("'" + this.ddlHetong_status.SelectedItem.Text + "',"); sbSQL.Append("'" + this.txtBaojia_end_dateFrom.Text.Trim() + "',"); sbSQL.Append("'" + this.txtBaojia_end_dateTo.Text.Trim() + "',"); sbSQL.Append("'" + "" + "',"); //--姓名 sbSQL.Append("'" + this.txtCreate_dateF.Text.Trim() + "',"); sbSQL.Append("'" + this.txtCreate_dateT.Text.Trim() + "',"); sbSQL.Append("'" + this.txtLjh.Text.Trim() + "',"); sbSQL.Append("'" + this.txtLj_Name.Text.Trim() + "',"); sbSQL.Append("'" + this.dropSales_Name.Text.Trim() + "'"); DataTable dt = DbHelperSQL.Query(sbSQL.ToString()).Tables[0]; //处理查无资料结果显示效果:添加一行显示友好一点 bool isEmpty = false; if (dt.Rows.Count == 0) { isEmpty = true; dt.Rows.Add(dt.NewRow()); } this.GridView1.DataSource = dt; this.GridView1.DataBind(); if (isEmpty == true) { int columnCount = dt.Columns.Count; GridView1.Rows[0].Cells.Clear(); GridView1.Rows[0].Cells.Add(new TableCell()); GridView1.Rows[0].Cells[0].ColumnSpan = columnCount; GridView1.Rows[0].Cells[0].Text = "没有记录"; GridView1.Rows[0].Cells[0].Style.Add("text-align", "center"); } ; if (isEmpty == false) { int[] cols = { 0, 1, 2, 3, 4, 5, 6, 25, 7, 20, 21, 22, 23, 24, 26, 18, 19, }; MergGridRow.MergeRow(GridView1, cols); //设定合并单元格后要显示连接的requestid int visbleRow = 0; for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { visbleRow = j; } else { GridView1.Rows[visbleRow].Cells[27].Text = GridView1.Rows[j].Cells[27].Text; } } int rowIndex = 1; for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { if (GridView1.Rows[j].Cells[0].Visible == true) { GridView1.Rows[j].Cells[0].Text = rowIndex.ToString(); HyperLink link = new HyperLink(); link.ID = "link" + rowIndex.ToString(); link.NavigateUrl = "Baojia.aspx?requestid=" + GridView1.Rows[j].Cells[27].Text; link.Text = GridView1.Rows[j].Cells[1].Text; link.Target = "_blank"; GridView1.Rows[j].Cells[1].Controls.Add(link); rowIndex++; } } } }