Click here to Skip to main content
14,699,869 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
i want to split a asp.net gridview column in to 3 sub column and i want to bind data to the each sub column from the database. does any one knows how to do the column split???
Posted
Updated 27-Dec-16 23:48pm
Comments
Sergey Alexandrovich Kryukov 21-Mar-12 21:31pm
   
Not clear. Suppose you had 4 columns. When you split one on three, you will have 7. Why not having all 7 "in first place". In other words, what is a sub-column? Still a column, unless you need a split not in every row.
--SA

Hello Xavier,

My Article on Gridview cell merging will help you to solve this issue, if you still have some questions let me know.

GridView Column header merging in Asp.net[^]

Thanks!!!!!
   
hi,
try the below solution,

1:protected void gridObj_ItemCreated(object sender, DataGridItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListItemType.Header:
DataGridItem headerItem = new DataGridItem(0, 0, ListItemType.Header);
TableCell tc;


tc = new TableCell();
tc.Text = "Mian Column";
tc.Width = Unit.Pixel(220);//Set Witdth
tc.ColumnSpan = 3;
headerItem.Cells.Add(tc);


gridObj.Controls[0].Controls.AddAt(0, headerItem);
break;
case ListItemType.Item:
break;
case ListItemType.SelectedItem:
case ListItemType.AlternatingItem:

break;
}
}

hopes this work for you...
   
This may help you
http://go4answers.webhost4life.com/Example/split-columns-gridview-136395.aspx[^]

Vinod Viswanath has given nice link
   
Comments
D-Kishore 29-Aug-12 6:53am
   
Yes Its working
protected void gridObj_ItemCreated(object sender, DataGridItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListItemType.Header:
DataGridItem headerItem = new DataGridItem(0, 0, ListItemType.Header);
TableCell tc;


tc = new TableCell();
tc.Text = "Mian Column";
tc.Width = Unit.Pixel(220);//Set Witdth
tc.ColumnSpan = 3;
headerItem.Cells.Add(tc);


gridObj.Controls[0].Controls.AddAt(0, headerItem); 
break;
case ListItemType.Item: 
break;
case ListItemType.SelectedItem:
case ListItemType.AlternatingItem:

break;
}
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900