gridview headers

S

ShiroiRyuu

tenho um dataset que tem um numero de colunas variavel que é
apresentado num grid view e eu queria podsr agrupar alguns headers
desse gridview quando as colunas possuirem o mesmo nome. por exemplo

é assim:


empresa | teste | teste | campo | alfa | alfa
---------------------------------------------------------------------------­-------



nome | 134 | 214 | 342 | 245 | 456
nome | 100 | 344 | 453 | 312 | 78


e eu quero que fique assim:


empresa | teste | beta | alfa
---------------------------------------------------------------------------­-------



nome | 134 | 214 | 342 | 245 | 456
nome | 100 | 344 | 453 | 312 | 78


alguem sabe como fazer isso?


obrigado!
 
F

Fred Exley

tenho um dataset que tem um numero de colunas variavel que é
apresentado num grid view e eu queria podsr agrupar alguns headers
desse gridview quando as colunas possuirem o mesmo nome. por exemplo

é assim:


empresa | teste | teste | campo | alfa | alfa
---------------------------------------------------------------------------­-------



nome | 134 | 214 | 342 | 245 | 456
nome | 100 | 344 | 453 | 312 | 78


e eu quero que fique assim:


empresa | teste | beta | alfa
---------------------------------------------------------------------------­-------



nome | 134 | 214 | 342 | 245 | 456
nome | 100 | 344 | 453 | 312 | 78


alguem sabe como fazer isso?


obrigado!



This might help a little. It dynamically builds the header text of a
gridview based on drop down list values:
(you can run it at: http://monte.jodoshared.com/FindAnItem.aspx (the
'Compare' page does this dynamic header manipulation))


protected void GridViewCompareSet_Sorting(object sender,
GridViewSortEventArgs e)

{




DataTable m_DataTable = (DataTable)Session["dtFinal"];

if (m_DataTable != null)

{

int m_PageIndex = GridViewCompareSet.PageIndex;

string m_SortDirection = GetSortDirection();

DataView m_DataView = new DataView(m_DataTable);

m_DataView.Sort = e.SortExpression + " " + m_SortDirection;

GridViewCompareSet.DataSource = m_DataView;

GridViewCompareSet.DataBind();

GridViewCompareSet.HeaderRow.Cells[1].Text =
DropDownList1.SelectedItem.ToString();

GridViewCompareSet.HeaderRow.Cells[2].Text =
DropDownList2.SelectedItem.ToString();

GridViewCompareSet.HeaderRow.Cells[0].Width = 100;

GridViewCompareSet.HeaderRow.Cells[1].Width = 90;

GridViewCompareSet.HeaderRow.Cells[2].Width = 90;


GridViewCompareSet.PageIndex = m_PageIndex;

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top