|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article describes a simple trick to merge the header columns of a BackgroundI found a similar solution: Merge DataGrid Header, but I wanted to do this in 2-3 lines of code. So, I tried to use the members of the Using the codeIn the C#private void Sub Datagrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e )
{
//If Header item
If (e.Item.ItemType = = ListItemType.Header)
{
e.Item.Cells.RemoveAt(2);
e.Item.Cells(1).ColumnSpan = 2;
//Insert the table shown in the diagram 3
// to the Text property of the Cell
e.Item.Cells(1).Text = "<table style='FONT-WEIGHT: bold; WIDTH:" +
" 100%; COLOR: white; TEXT-ALIGN: center'><tr align" +
" =center><td colspan = 2 style='BORDER-BOTTOM:" +
" cccccc 1pt solid'>Name</td></tr>" +
"<tr align =center ><td style ='BORDER-RIGHT:" +
" cccccc 1pt solid'>F Name</td><td>L" +
" Name</td></tr></table>";
}
}
VB.NETPrivate Sub Datagrid1_ItemCreated(ByVal sender As _
Object, ByVal e System.Web.UI.WebControls.DataGridItemEventArgs)_
Handles Datagrid1_ItemCreated
'If Header item
If e.Item.ItemType = ListItemType.Header Then
e.Item.Cells.RemoveAt(2)
e.Item.Cells(1).ColumnSpan = 2
'Insert the table shown in the diagram 3 to the Text property of the Cell
e.Item.Cells(1).Text = "<table style='FONT-WEIGHT: bold;" & _
" WIDTH: 100%; COLOR: white; TEXT-ALIGN: center'><tr" & _
" align =center><td colspan = 2 style='BORDER-BOTTOM:" & _
" cccccc 1pt solid'>Name</td></tr>" & _
"<tr align =center ><td style ='BORDER-RIGHT:" & _
" cccccc 1pt solid'>F Name</td><td>L" & _
" Name</td></tr></table>"
End If
End Sub
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||