protected void btnsave_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { try { if (ddlLocations.SelectedValue.Equals("")) { throw new Exception("Select a valid Location."); } Stream fileStream = FileUpload1.PostedFile.InputStream; //turns it into a list here called temperatureList and is bound. need to save in database instead. List <Temperature> temperatureList = DataProcessor.ReadCsvFile(fileStream); int locationId = int.Parse(ddlLocations.SelectedValue); ClassFunctions.BulkTemperatureDataInsert(temperatureList, locationId); txtLocation.InnerText = ddlLocations.SelectedItem.Text; txtRowcount.InnerText = temperatureList.Count.ToString(); feedbackSuccess.Visible = true; } catch (Exception ex) { txtFail.InnerText = ex.Message; feedbackDanger.Visible = true; } } }