我有这段代码用 csv 文件填充我的 gridview。我需要隐藏一些列,但不知道在代码中的哪个位置进行此操作。我真的需要帮助,所以请避免评论我如何向您展示或给我减分,因为我的语法不好。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
namespace SeccurisCsvReader
{
public partial class gridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void csvButton_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.FileName == string.Empty)
{
lblMsg.Visible = true;
return;
}
else
{
string[] FileExt = FileUpload1.FileName.Split('.');
string FileEx = FileExt[FileExt.Length - 1];
if (FileEx.ToLower() == "csv")
{
FileUpload1.SaveAs(Server.MapPath(" " + FileUpload1.FileName));
}
else
{
lblMsg.Visible = true;
return;
}
}
CSVReader reader = new CSVReader(FileUpload1.PostedFile.InputStream);
string[] headers = reader.GetCSVLine();
DataTable dt = new DataTable();
foreach (string strHeader in headers)
dt.Columns.Add(strHeader);
string[] data;
while ((data = reader.GetCSVLine()) != null)
dt.Rows.Add(data);
CsvGridView.DataSource = dt;
CsvGridView.DataBind();
}
}
}
Now where do I start!!!