Hello Member 10850253,
This is how I would do it:
) Upload your file to your repository folder.
) List the available file(s) in a listbox or similar control.
) Once a file name is selected form the above list, run the GetExcelSheetNames method to populate your combobox(dropdownlist).
) Once a sheet name is selected from such control, run the Import_To_Grid method.
Things to consider:
) Page_Load event must make sure to load the available/selected FileList and SheetList controls. Personally, if there is only one file, I would automatically select it in order o populate the SheetList; if there are more, then pre-select the most recent one. Make use of "IsPostBack" to avoid unnecessary workload.
) In your Import_To_Grid, query the selected sheet, where Sheet1$ = Selected Sheet Name:
OleDbCommand objCmd = new OleDbCommand("Select * From [Sheet1$]", objConn);
By the way, also consider implementing an "available files cleaning" routine to avoid accumulating files upon files upon files.
Hope this helps you get on track.