---
title: "when i upload excel file dynamically display dropdowns in header of gridview columns."  
description: "when i upload excel file dynamically display dropdowns in header of gridview columns."  
author: "Munikumar G"  
published: 2012-04-19  
updated: 2012-04-20  
canonical: https://www.mindstick.com/forum/407/when-i-upload-excel-file-dynamically-display-dropdowns-in-header-of-gridview-columns  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# when i upload excel file dynamically display dropdowns in header of gridview columns.

Hi,

when i [upload](https://www.mindstick.com/forum/12860/how-to-upload-file-asynchronously-using-generic-handler) excel [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp), dynamically display dropdowns in [header](https://www.mindstick.com/articles/336036/explain-about-html-header-body-and-footer-tags) of [gridview](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) columns.

i am using this code

```
//Check file is available in File upload Controlif (FileUpload1.HasFile){//Store file name in the string variablestring filename = FileUpload1.FileName;//Save file upload file in to server path for temporaryFileUpload1.SaveAs(Server.MapPath(filename));//Export excel data into Gridview using below methodExportToGrid(Server.MapPath(filename));}}void ExportToGrid(String path){OleDbConnection MyConnection = null;DataSet DtSet = null;OleDbDataAdapter MyCommand = null;//Connection for MS Excel 2003 .xls formatMyConnection =new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + path + "';Extended Properties=Excel 8.0;");//Connection for .xslx 2007 formatMyConnection =new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + path + "';Extended Properties=Excel 12.0;");//Connection for .xslx 2010 format//MyConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.14.0;Data Source='" + path + "';Extended Properties=Excel 14.0;");//Select your Excel fileMyCommand =new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);DtSet =new System.Data.DataSet();//Bind all excel data in to data setMyCommand.Fill(DtSet,"[Sheet1$]");dt = DtSet.Tables[0];MyConnection.Close();//Check datatable have records           if (dt.Rows.Count > 0){GridView1.DataSource = dt;GridView1.DataBind();}//Delete temporary Excel file from the Server pathif (System.IO.File.Exists(path)){System.IO.File.Delete(path);}
```

use munlti headers also......... sort out ASAP.

Thanks

Munikumar

## Replies

### Reply by Anonymous User

Hi Munikumar,

Please! Explain your question clearly; what are you trying to ask? Check out following helpful link...

[https://www.mindstick.com/blog/294/how-to-import-or-export-sql-server-table-data-in-ms-excel-sheet-using-c-sharp-code](https://www.mindstick.com/blog/294/how-to-import-or-export-sql-server-table-data-in-ms-excel-sheet-using-c-sharp-code)\

[https://www.mindstick.com/forum/373/how-to-import-data-from-excel-to-datatable-in-c-sharp](https://www.mindstick.com/forum/373/how-to-import-data-from-excel-to-datatable-in-c-sharp)

I hope it might be resolve your problem.\


---

Original Source: https://www.mindstick.com/forum/407/when-i-upload-excel-file-dynamically-display-dropdowns-in-header-of-gridview-columns

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
