Example #1
0
    public void Bind(int Page)
    {
        member = (Member)Session["Member"];

        int NumberOfPhotos = Photo.GetPhotoCountPhotoCollectionID(DefaultPhotoCollectionID);

        photos = Photo.GetPhotoByPhotoCollectionIDWithJoinPager(DefaultPhotoCollectionID, Page, 10);

        PhotoCollection LocalGallery = new PhotoCollection(DefaultPhotoCollectionID);

        GalleryName = LocalGallery.Name + " (" + NumberOfPhotos + ")";

        // bit if a hack to get the webphotocollectionID
        photoCollections = member.PhotoCollection;
        for (int i = 0; i < photos.Count; i++)
        {
            PhotoCollection photoCol = GetLocalGalleryByPhotoColletionID(photos[i].PhotoCollectionID);
            photos[i].WebPhotoCollectionID = photoCol.WebPhotoCollectionID;
        }


        Pager pager = new Pager("/myphotos/", Page, NumberOfPhotos);

        pager.PageSize            = 10;
        pager.MiscParameterString = (DefaultWebPhotoCollectionID != null) ? "pc=" + DefaultWebPhotoCollectionID : string.Empty;
        PagerHTML = pager.ToString();

        PhotoRepeater.DataSource = photos;
        PhotoRepeater.DataBind();
    }
Example #2
0
        protected void PhotoCallbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
        {
            List <AdvertPhoto> photoList  = new List <AdvertPhoto>();
            DataTable          PhotoTable = new DataTable();

            int rowIndex = int.TryParse(e.Parameter, out int result) ? result : -1;

            if (rowIndex >= 0)
            {
                int ads_photo_id = PhotoGridView.GetRowValues(rowIndex, "ads_photo_id") as int? ?? 0;
                using (var cnn = new SqlConnection(connectionString))
                {
                    cnn.Open();
                    using (var cmd = cnn.CreateCommand())
                    {
                        cmd.CommandText = "SELECT * FROM dbo.AdvertPhotos WHERE ads_photo_id = @ads_photo_id";
                        cmd.Parameters.Add("@ads_photo_id", SqlDbType.Int).Value = ads_photo_id;
                        PhotoTable.Load(cmd.ExecuteReader());
                        foreach (DataRow row in PhotoTable.Rows)
                        {
                            photoList.Add(new AdvertPhoto()
                            {
                                ads_photo_id = int.Parse(row["ads_photo_id"].ToString()),
                                ads_id       = int.Parse(row["ads_id"].ToString()),
                                file_name    = row["file_name"].ToString(),
                                photo        = (byte[])row["photo"]
                            });
                            row["url"] = string.Format("~/PhotoHandler.ashx?ads_photo_id={0}", row["ads_photo_id"].ToString());
                            PhotoTable.AcceptChanges();

                            Session["photo_url"]     = photoList;
                            PhotoRepeater.DataSource = PhotoTable;
                            PhotoRepeater.DataBind();
                        }
                    }
                }
            }
        }