Your code will never run because of these two lines
if (Path.GetExtension(FileUpload.FileName).ToLower() == ".xlsx")
{
if (Path.GetExtension(FileUpload.FileName).ToLower() == ".xls")
The file extension cannot be both ".xlsx" AND ".xls" it must be one or the other.
I suspect that you wanted to use
if (Path.GetExtension(FileUpload.FileName).ToLower() == ".xlsx" ||
Path.GetExtension(FileUpload.FileName).ToLower() == ".xls")
{
ExcelPackage package = new ExcelPackage(FileUpload.FileContent);
dt = package.ToDataTable();
for(int i=0;i<=dt.Rows.Count-1;i++)
I haven't checked the rest of it, but you need to use the debugger to find out what is going on if it still doesn't work. This article will help you
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]