.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to make a column as a row header in Gridview

Posted By: Shanthini     Posted Date: June 17, 2009    Points:2   Category :ASP.Net
In an application, i want to make a fixed column as a row header in Gridview. Please provide me C# ASP .NET Code for proceeding....

xxx yyy zzzz
AAAAAA 1 2 3
BBBBBB 1 2 3
CCCCCC 1 2 3
DDDDDD 1 2 3

How to display that AAAAAA, BBBBBB, CCCCCC, DDDDDD in gridview in C# ??

Responses
Author: Amit Mehra             
Posted Date: June 17, 2009     Points: 5   

HI,
the best way to flip the datatable or dataset and than assign the dataset to gridview.
to flip dataset here is the code

public DataSet FlipDataSet(DataSet my_DataSet)
{
DataSet ds = new DataSet();
foreach(DataTable dt in my_DataSet.Tables)
{
DataTable table = new DataTable();
for(int i=0; i<=dt.Rows.Count; i++)
{
table.Columns.Add(Convert.ToString(i));
}
DataRow r;
for(int k=0; k<dt.Columns.Count; k++)
{
r = table.NewRow();
r[0] = dt.Columns[k].ToString();
for(int j=1; j<=dt.Rows.Count; j++)
r[j] = dt.Rows[j-1][k];
}
table.Rows.Add(r);
}
ds.Tables.Add(table);
}
return ds;
}


Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Clintonzz             
Posted Date: May 07, 2014     Points: 20   

Don't know this gridview row header formatting be helpful or not:

http://www.kettic.com/winforms_ui/csharp_guide/gridview_grouping_format_header.shtml



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend