//TODO: // CHANGE THE IMAGE ARRAY TO IMAGES LIST public void addCourt_Click(object sender, EventArgs e) { int courtId; string lat = hiddenValue.Value; string lng = hiddenValue1.Value; int climit = getSelectedIndex(courtLimit.SelectedIndex); //string[] images = new string[5]; List <String> images = new List <string>(); string path2 = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); string path = Server.MapPath("~/FieldImages/"); Courts court = new Courts(courtName.Text, courtCity.Text, climit, lat, lng); bool isAdded = court.addField(); courtId = court.id; if (isAdded) { try { if (imageUpload.HasFile) { int count = 0; string folder = courtId.ToString(); DirectoryInfo di = Directory.CreateDirectory(path + folder); foreach (HttpPostedFile file in imageUpload.PostedFiles) { if (count > 4) { break; } string ext = Path.GetExtension(file.FileName).ToLower(); file.SaveAs(di.FullName + @"\" + count + ext); //images[count] = count + ext; images.Add(count + ext); count++; } } else { images = null; } } catch { } string err = court.addImages(courtId, images, path2); Response.Redirect("~/SuccessPage.aspx?courtId=" + courtId); } }