Beispiel #1
0
        protected void gvAutos_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (!(e.Row.DataItem is Automobile))
            {
                return;
            }
            var auto = e.Row.DataItem as Automobile;

            e.Row.Cells[3].Text = auto.IsApproved == 1 ? "Yes" : "No";
            var btnA = e.Row.Cells[9].FindControl("btnApprove");
            var btnU = e.Row.Cells[9].FindControl("btnUnapprove");

            btnU.Visible = auto.IsApproved == 1;
            btnA.Visible = auto.IsApproved == 0;

            var btnMh       = e.Row.Cells[9].FindControl("btnMakeHighlight");
            var btnRh       = e.Row.Cells[9].FindControl("btnRemoveHighlight");
            var isHighlight = auto.IsHighlight.ToString();

            e.Row.Cells[4].Text = isHighlight == "1" ? "Yes" : "No";
            btnMh.Visible       = isHighlight == "0";
            btnRh.Visible       = isHighlight == "1";
            var img   = e.Row.Cells[9].FindControl("imgMain") as Image;
            var image =
                _autoManager.GetImagesByAutoId(auto.Id, true).FirstOrDefault();

            if (image == null)
            {
                return;
            }
            img.ImageUrl = image.Url;
        }
Beispiel #2
0
        protected void gvAutos_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.Cells.Count < 5)
            {
                return;
            }
            var hf = e.Row.Cells[4].FindControl("hfId") as HiddenField;

            if (hf == null)
            {
                return;
            }
            var auto = (Automobile)e.Row.DataItem;
            var img  = e.Row.Cells[4].FindControl("imgMain") as Image;
            // ReSharper disable PossibleNullReferenceException
            var image =
                _autoManager.GetImagesByAutoId(auto.Id, true).FirstOrDefault();

            img.ImageUrl = image == null ? "" : image.Url;
            // ReSharper restore PossibleNullReferenceException
        }