Veritabanından kimliğe göre görüntüleri almak (almak) için aşağıdakilere sahibim (tüm bu görüntülerin bir kimliği vardır). SonraAsp.net mvc'de neden ilgili görüntü veritabanından alınmıyor?
<img src="@Url.Action("GetMainPicture", "Product", new { item.ProductID, @class = "img-responsive" })" alt="" />
i Popup için ve ben resmi getirilirken için kullanılan kod aynı çizgiyi kullanılan açılır içine çağıran bir <a href>
etiketine sahip, burada bu:
<img src="@Url.Action("GetMainPicture", "Product", new { item.ProductID, @class = "img-responsive" })" alt="" />
yukarıdaki satırı kod resimi alır ancak problem, her resim için görüntüyü id = 1 ile getirmesidir. Online
sorunun ne@model List<Hosay.Domain.Entities.Product>
@foreach (var item in Model)
{
<!-- PRODUCT ITEM START -->
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="product-item">
<div class="pi-img-wrapper">
<img src="@Url.Action("GetMainPicture", "Product", new { item.ProductID, @class = "img-responsive" })" height="300" width="230" alt="" />
<div>
<a href="../../assets/frontend/pages/img/products/model1.jpg" class="btn btn-default fancybox-button">Zoom</a>
<a href="#product-pop-up" class="btn btn-default fancybox-fast-view">View</a>
</div>
</div>
<h3>@Html.ActionLink(item.ProductName, "ProductDetails", new { item.ProductID })</h3>
<div class="pi-price">@item.ProductPrice.ToString("c")</div>
<a href="javascript:;" class="btn btn-default add2cart">Add to cart</a>
</div>
</div>
<!-- PRODUCT ITEM END -->
<!--Product Quick View Start-->
<div id="product-pop-up" style="display: none; width: 700px;">
<div class="product-page product-pop-up">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-3">
<div class="product-main-image">
<img src="@Url.Action("GetMainPicture", "Product", new { item.ProductID })" class="img-responsive" alt="" />
</div>
<div class="product-other-images">
<a href="javascript:;" class="active"><img alt="Berry Lace Dress" src="~/Images/Products/model3.jpg"></a>
<a href="javascript:;"><img alt="Berry Lace Dress" src="~/Images/Products/model4.jpg"></a>
<a href="javascript:;"><img alt="Berry Lace Dress" src="~/Images/Products/model5.jpg"></a>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-9">
<h2>Cool green dress with red bell</h2>
<div class="price-availability-block clearfix">
<div class="price">
<strong><span>$</span>47.00</strong>
<em>$<span>62.00</span></em>
</div>
<div class="availability">
Availability: <strong>In Stock</strong>
</div>
</div>
<div class="description">
<p>
Lorem ipsum dolor ut sit ame dolore adipiscing elit, sed nonumy nibh sed euismod laoreet dolore magna aliquarm erat volutpat
Nostrud duis molestie at dolore.
</p>
</div>
<div class="product-page-options">
<div class="pull-left">
<label class="control-label">Size:</label>
<select class="form-control input-sm">
<option>L</option>
<option>M</option>
<option>XL</option>
</select>
</div>
<div class="pull-left">
<label class="control-label">Color:</label>
<select class="form-control input-sm">
<option>Red</option>
<option>Blue</option>
<option>Black</option>
</select>
</div>
</div>
<div class="product-page-cart">
<div class="product-quantity">
<input id="product-quantity" type="text" value="1" readonly name="product-quantity" class="form-control input-sm">
</div>
<button class="btn btn-primary" type="submit">Add to cart</button>
<a href="shop-item.html" class="btn btn-default">More details</a>
</div>
</div>
<div class="sticker sticker-sale"></div>
</div>
</div>
</div>
<!--Product Quick View End-->
}
, ben buldum olamazdı şey bu yüzden burada sordum: derinlemesine bilgi vermek için ben aşağıda tüm kodu yapıştırın.
DÜZENLEME:
public FileContentResult GetMainPicture(int productId)
{
Product prod = repository.Products
.FirstOrDefault(p => p.ProductID == productId);
if (prod != null)
{
return File(prod.MainPicture, prod.MainPictureMimeType);
}
else
{
return null;
}
}
Naser aynı kimliğe sahip birden bölüm oluşturacağız -loop for
İçinde
Lütfen "GetMainPicture" için kaynak kodunu ekleyin. –
@PeterB Soru güncellendi! lütfen bir göz atın .. –