0

I need to do something like this.

enter image description here

I tried using switch statement and this is the result

enter image description here

Now I tried a different approach. I saved the file path of the image in the database. Then retrieve the file path from the database so that it will display the corresponding image and this is the result

enter image description here

instead of displaying the image it displayed the image path from the database. How can I resolve this?

Here's my code:

_DeliveryDetailsPartial

    <h5 style="text-transform:uppercase; padding-left:5px; margin-top:10px; font-weight:bold">Payments Accepted</h5>
    @foreach (StoreAcceptedPayment payment in Model.Item4)
    {
        <span class="col-md-3">@Html.DisplayFor(model => payment.ImgPath)</span>
    }

DeliverController

public ActionResult GetStoreDetails(string id)
    {
        var store = new Tuple<List<Store>, List<StoreHour>, List<StoreHour>, List<StoreAcceptedPayment>>
        (_repo.GetStore(int.Parse(id)), _repo.GetStoreHourByDay(dayOftheWeek), _repo.GetStoreHourByID(int.Parse(id)), _repo.GetAcceptedPayment(int.Parse(id)));

        return View(store);
    }

Thanks in advance..

2 Answers 2

1

Please do like below.

<span class="col-md-3">@Html.DisplayFor(model => payment.ImgPath)</span>

Instead of the above code please use the below one.

<span class="col-md-3">
    <img src="~/Images/@payment.ImgPath" alt=""  />
</span>
Sign up to request clarification or add additional context in comments.

Comments

1

If you have only filename in Model then you have to do this way using img tag utilizing its src attribute:

@foreach (StoreAcceptedPayment payment in Model.Item4)
{
   <img src="@Url.Content("~/"+payment.ImgPath)" />
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.