无法将行转换为列 [英] Couldn't able to convert rows to columns
问题描述
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn(Col1,typeof(string)) );
dt.Columns.Add(new DataColumn(Col2,typeof(string)));
dt.Columns.Add(new DataColumn(Col3) ,typeof(string)));
dt.Columns.Add(new DataColumn(Col4,typeof(string)));
dr = dt.NewRow( );
dr [Col1] = string.Empty;
dr [Col2] = string.Empty;
dr [ Col3] = string.Empty;
dr [Col4] = string.Empty;
dr = dt.NewRow( );
dr [ Col1] = string 跨度> .Empty;
dr [ Col2] = string 跨度> .Empty;
dr [ Col3] = string 跨度> .Empty;
dr [ Col4] = string .Empty;
dr = dt.NewRow();
ViewState [CurrentTable] = dt;
在页面加载时,我曾经在gridview中加载2行。 gridview与BoundField绑定..
我需要将2行转换为列。浏览了很多网站,但没有发生任何变化....任何人都可以分享我的apt网站将行转换为列....
检查此链接
使用C#转置DataTable [ ^ ]
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("Col1", typeof(string)));
dt.Columns.Add(new DataColumn("Col2", typeof(string)));
dt.Columns.Add(new DataColumn("Col3", typeof(string)));
dt.Columns.Add(new DataColumn("Col4", typeof(string)));
dr = dt.NewRow();
dr["Col1"] = string.Empty;
dr["Col2"] = string.Empty;
dr["Col3"] = string.Empty;
dr["Col4"] = string.Empty;
dr = dt.NewRow();
dr["Col1"] = string.Empty;
dr["Col2"] = string.Empty;
dr["Col3"] = string.Empty;
dr["Col4"] = string.Empty;
dr = dt.NewRow();
ViewState["CurrentTable"] = dt;
On page load, I used to load 2 rows in gridview. The gridview is bound with the BoundField..
I need to convert the 2 rows to columns wise. Surfed many websites but no changes are happening.... Can anyone share me the apt website to convert rows to columns....
check this link
Transpose a DataTable using C#[^]
这篇关于无法将行转换为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!