如何删除datatable中的列名 [英] how can remove the column name in datatable
本文介绍了如何删除datatable中的列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
以下代码用于设置新datatable.one时间的列标题。但是第二次出现相同的列标题在数据表中。所以它会造成错误。我想在每次执行此方法时刷新表。如何删除列标题。
Hi friends,
The below code is for setting column header for a new datatable.one time it is worked.but in second time The same column header appeared in the datatable. so it makes error. I want to refresh the table every time i executed this method. how can delete the column header.
public DataTable setgrid(DataTable studlist,DataTable subjectlist,business.Commonpropertis comp)
{
string marktype1 = "Internal Mark";
string marktype2 = "External Mark";
string divide="|";
DataTable grid = null;
grid = new DataTable();
for (int i = 0; i < studlist.Columns.Count; i++)
{
grid.Columns.Add(studlist.Columns["AdmissionNumber"].ColumnName.ToString());
grid.Columns.Add(studlist.Columns["RollNumber"].ColumnName.ToString());
grid.Columns.Add(studlist.Columns["Name"].ColumnName.ToString());
}
推荐答案
您不需要循环只需创建一次列。
You don't need a loop just create the columns once.
这篇关于如何删除datatable中的列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文