Пример #1
0
        private void Bind()
        {
            Dictionary <string, string> dicPicture = new Dictionary <string, string>();

            if (!productItemId.Equals(Guid.Empty))
            {
                ProductImage bll   = new ProductImage();
                var          model = bll.GetModel(productItemId);
                if (model != null)
                {
                    var li = ddlProductItem_ProductImage.Items.FindByValue(model.ProductItemId.ToString());
                    if (li != null)
                    {
                        li.Selected = true;
                    }

                    XElement xel = XElement.Parse(model.PictureAppend);
                    var      q   = from x in xel.Descendants("Add")
                                   select new { pictureId = x.Attribute("PictureId").Value };

                    StringBuilder sbInIds = new StringBuilder(1000);

                    foreach (var item in q)
                    {
                        sbInIds.AppendFormat("'{0}',", item.pictureId);
                    }

                    PictureProduct ppBll       = new PictureProduct();
                    var            pictureList = ppBll.GetListInIds(sbInIds.ToString().Trim(','));
                    if (pictureList != null && pictureList.Count > 0)
                    {
                        foreach (var picModel in pictureList)
                        {
                            dicPicture.Add(picModel.Id.ToString(), PictureUrlHelper.GetMPicture(picModel.FileDirectory, picModel.RandomFolder, picModel.FileExtension));
                        }
                    }
                }
            }

            if (dicPicture.Count == 0)
            {
                dicPicture.Add("", "../../Images/nopic.gif");
            }

            rpData.DataSource = dicPicture;
            rpData.DataBind();
        }