protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { Table tbl = e.Row.Parent as Table; TableCell cell = new TableCell(); CheckBox chk = new CheckBox(); Label lbl2 = new Label(); HiddenField rowValue = new HiddenField(); if (e.Row.RowType == DataControlRowType.Header) { e.Row.Visible = false; } else { if (e.Row.RowType == DataControlRowType.DataRow) { Session["count"] = 1; Label lbl = (Label)e.Row.FindControl("lblValue"); string str1 = ((Label)(lbl)).Text; string prevStr = (string)Session["previousStr"]; if (prevStr == str1) { lbl.Visible = false; lbl.Text = string.Empty; counter += 1; Session["count"] = (int)Session["count"] + counter; } else { prevStr = sr1; Session["previousStr"] = prevStr; if (tbl != null) { GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal); rowValue.ID = "hdnNumRows"; rowValue.Value = Convert.ToString(Session["count"]); lbl2.Text = Convert.ToString(Session["count"]); cell.ColumnSpan = this.GridView1.Columns.Count; cell.Width = Unit.Percentage(100); cell.BackColor = System.Drawing.Color.Aqua; HtmlGenericControl span = new HtmlGenericControl("span"); span.InnerHtml = prevStr; cell.Controls.Add(span); cell.Controls.Add(chk); cell.Controls.Add(lbl2); cell.Controls.Add(rowValue); row.Cells.Add(cell); tbl.Rows.AddAt(tbl.Rows.Count - 1, row); } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)