Hi,
I am using gridview with 23 columns.The first column i have template field with link button(Edit) option, second column is the primary id column, the remaining columns are necessary columns.After 5th column, 7 columns comes under common column name like A,the remaining number of columns comes under some other common column name like B. The common column name A and B are merge successfully but the link button(Edit) is not working correctly. Without using merge option the link button(Edit) is working correctly.
What can i do for that?
Update:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
GridViewRow gvRow = e.Row;
if (gvRow.RowType == DataControlRowType.Header)
{
if (gvRow.Cells[0].Text == "Edit")
{
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
gvRow.Cells.Remove(gvRow.Cells[0]);
GridViewRow gvHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell headerCell0 = new TableCell()
{
Text = "Edit",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2,
};
TableCell headerCell1 = new TableCell()
{
Text = "lite_id",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2
};
TableCell headerCell2 = new TableCell()
{
Text = "Quarter",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2
};
TableCell headerCell3 = new TableCell()
{
Text = "Contract No",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2
};
TableCell headerCell4 = new TableCell()
{
Text = "BP Name",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2
};
TableCell headerCell5 = new TableCell()
{
Text = "City",
HorizontalAlign = HorizontalAlign.Center,
RowSpan = 2
};
TableCell headerCell6 = new TableCell()
{
Text = "Target",
HorizontalAlign = HorizontalAlign.Center,
ColumnSpan = 7
};
TableCell headerCell7 = new TableCell()
{
Text = "Achievement",
HorizontalAlign = HorizontalAlign.Center,
ColumnSpan = 9
};
gvHeader.Cells.Add(headerCell0);
gvHeader.Cells.Add(headerCell1);
gvHeader.Cells.Add(headerCell2);
gvHeader.Cells.Add(headerCell3);
gvHeader.Cells.Add(headerCell4);
gvHeader.Cells.Add(headerCell5);
gvHeader.Cells.Add(headerCell6);
gvHeader.Cells.Add(headerCell7);
GridView1.Controls[0].Controls.AddAt(0, gvHeader);
}
}
}
catch (Exception ex)
{
errorLabel.Text = ex.ToString();
}
}