I have input data in excel and csv format.so depending upon whether user is giving excel or csv ,i have to use that.i have attached the code.
if (excelfileupload.HasFile)
{
String FilePath = Server.MapPath("~/Files/FileName.csv");
System.IO.File.Delete(FilePath);
DropDownList1.Visible = true;
DataSet excelds = (DataSet)Session["excelDataSet"];
DataTable samples = excelds.Tables[0];
ArrayList rowcontents = new ArrayList();
if (samples.Rows.Count > 0)
{
for (int j = 0; j < samples.Columns.Count; j++)
{
rowcontents.Add(samples.Columns[j].ColumnName);
}
}
DropDownList1.DataSource = rowcontents;
DropDownList1.DataBind();
}
if (csvfileupload.HasFile)
{
DropDownList1.Visible = true;
DataSet csvds = (DataSet)Session["csvDataSet"];
DataTable csvsamples = csvds.Tables[0];
ArrayList csvrowcontents = new ArrayList();
if (csvsamples.Rows.Count > 0)
{
for (int j = 0; j < csvsamples.Columns.Count; j++)
{
csvrowcontents.Add(csvsamples.Columns[j].ColumnName);
}
}
DropDownList1.DataSource = csvrowcontents;
DropDownList1.DataBind();
}
if am using first excel,then csv,both are working.but if again i am using excel,(since csv is now also having its uploaded file)it is showing column names of csv file only.I want to show column names of file that i have chosen then.how i can do this. after excel,csv file is coming.But if i am uploading excel after csv,then the column names of the old csv file is shown in the drop down list.
I am uploading excel and csv file from master page menu only.how i can correct the problem