Seven price
asked on
Convert Datatable to Dataset
How can I read from my datatable make it into a dataset.
private object ReadToEnd(string filePath)
{
string path = Server.MapPath("~/UploadFiles/" + ["fileName"] + ".CSV");
DataTable dtDataSource = new DataTable();
string[] fileContent = File.ReadAllLines(path);
if (fileContent.Count() > 0)
{
//Create data table columns
string[] columns = fileContent[0].Split(',');
for (int i = 0; i < columns.Count(); i++)
{
dtDataSource.Columns.Add(columns[i]);
}
//Add row data
for (int i = 1; i < fileContent.Count(); i++)
{
string[] rowData = fileContent[i].Split(',');
dtDataSource.Rows.Add(rowData);
}
}
return dtDataSource;
}
gv_GridView.DataSource = (DataTable)ReadToEnd(Request.QueryString["fileName"] + ".CSV");
gv_GridView.DataBind();
lbl_ErrorMsg.Visible = false;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tks
ASKER
Open in new window