protected void BindMainGallery() { try { using (EConnectContext context = new EConnectContext()) { mltvGallery.ActiveViewIndex = 0; var gallery = from p in context.PhotoGallery where p.IsVisible == true && p.ActiveFrom <= DateTime.Now && p.ActiveTill >= DateTime.Now select new { GalleryName = p.Name, ID = p.ID, //Title = c.Title, //Description = c.Description, //ImgPath = c.ImageFilePath, //ImgContent = c.ImageFileContent, //ImgName = c.ImageFileName }; LiteralControl li = new LiteralControl(); if (gallery.Count() > 0) { foreach (var g in gallery.ToList()) { var photoGallery = context.Gallery.Where(a => a.GalleryID == g.ID && a.IsHome == true && a.IsVisible == true).ToList().FirstOrDefault(); li = new LiteralControl(); if (photoGallery != null) { //li.Text = "<a href="#">"+g.GalleryName+"</a>"; if (File.Exists(Server.MapPath("~/" + photoGallery.ImageFilePath))) { li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>"; } else { string fileID = Guid.NewGuid().ToString(); FileStream fsImg = new FileStream(Server.MapPath("~/Docs/" + fileID + photoGallery.ImageFileName), FileMode.Create, FileAccess.Write); string filePath = "Docs/" + fileID + photoGallery.ImageFileName; Byte[] imgBytes = photoGallery.ImageFileContent; fsImg.Write(imgBytes, 0, imgBytes.Length); fsImg.Close(); li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>"; } } else { li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>"; } divMain.Controls.Add(li); } } li = new LiteralControl(); li.Text = "<div style="border-style:dashed;padding:0 10px 0 10px;removed:absolute;margin-removed20px;"><a style="text-decoration:none;" href="\"#\"" önclick="showModalPopUp();"><div>+</div></a></div>"; divMain.Controls.Add(li); }; } catch (Exception ex) { ShowAlert(ex.Message); } }
<div id="divMain" runat="server" style="min-height:700px;" class="main">
Css Class=.main { float: left; height: auto; width: auto; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)