First Bind data to gridview control in page load event.
private string Column1 = "";
protected void grd_RowDataBound(object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView
dr = (DataRowView)e.Row.DataItem;
Table
tbl = e.Row.Parent as Table;
if
(Column1!= dr["Column1"].ToString())
{
Column1=
dr["Column1"].ToString();
GridViewRow
rowHeader = new GridViewRow(-1,
-1, DataControlRowType.DataRow, DataControlRowState.Normal);
Literal
newCells = new Literal();
newCells.Text = dr["Header"].ToString();
TableHeaderCell
headerCell = new TableHeaderCell();
headerCell.Controls.Add(newCells);
headerCell.ColumnSpan =
e.Row.Cells.Count;
headerCell.BackColor = System.Drawing.Color.Silver;
headerCell.HorizontalAlign = HorizontalAlign.Left;
rowHeader.Cells.Add(headerCell);
rowHeader.Visible = true;
grd.Controls[0].Controls.AddAt(tbl.Rows.Count-1,
rowHeader);
}
}
Leave your comment below !!
Comments
Post a Comment