Hi,
Can anyone help me for merge Header column in gridview?
Thanks In Advance,
Jitendra Patel
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
piyush sardhara177 reputationPosted Apr 8, 2011, 1:41 AM EDT
that see get answer
piyush sardhara177 reputationPosted Apr 8, 2011, 1:42 AM EDT
asp:GridView ID="gvCustom" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="5" OnPageIndexChanging="gvPaging" OnRowCreated="gvCustom_RowCreated">Finally write the following code in the RowCreated event
C#
protected void gvCustom_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { GridView header = (GridView)sender; GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell tCell = new TableCell(); tCell.Text = "DevCurry Employee Information"; tCell.ColumnSpan = 4; tCell.HorizontalAlign = HorizontalAlign.Center; gvr.Cells.Add(tCell); // Add the Merged TableCell to the GridView Header Table tbl = gvCustom.Controls[0] as Table; if (tbl != null) { tbl.Rows.AddAt(0, gvr); } } } using that code create custom header or rowsaravanan subramanian15 reputationPosted Apr 8, 2011, 2:30 AM EDT
try this link:
http://shawpnendu.blogspot.com/2010/01/merge-merging-or-split-spliting.html
Regard
Saravanan.s
Jitendra Patel138 reputationPosted Apr 8, 2011, 3:24 AM EDT
I have also got the soluation.
In grid rowdatabound event write code,
which row you have to merge start it's loop to end columns..
If e.Row.RowType = DataControlRowType.Header Then
Dim dg As GridView = grvReviewDetails
Dim tb As Table = dg.Controls(0)
Dim tr As GridViewRow
Dim j As Integer
tr = tb.Rows(tb.Rows.Count - 1)
tr.Cells(2).ColumnSpan = 4
For j = 3 To 6
tr.Cells(j).Visible = False
tr.Cells(2).Visible = True
tr.Cells(2).Text = "Rating"
tr.Cells(2).HorizontalAlign = HorizontalAlign.Center
Next
tr.Cells(6).Visible = True
tr.Cells(6).Text = "Remarks"
End If
It's work perfectly.
Again thanks for your replay,
Keep it up,