Click here to Skip to main content
15,918,617 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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);
    }
}


Aspx code
<div id="divMain"  runat="server" style="min-height:700px;" class="main">


CSS
Css Class=.main
{
float: left;
    height: auto;
    width: auto;
 
}
Posted
Updated 6-Jun-14 21:22pm
v2
Comments
So, what is the issue?
Neha Mukesh 7-Jun-14 5:53am    
div is displayed at bottom not after the images??
Check the source html and see what CSS properties are making it to display at the bottom. Correct that.
ZurdoDev 7-Jun-14 21:52pm    
You'll have to debug it and see what's wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900