0

I want to pass a string variable to a partial view but im not sure how to display the string parameter to the partial view. Can anyone help me?

Here is my code:

Controller:

[HttpPost]
        public ActionResult CasIndex(int Sid)
        {

            string treat = dbContext.DogTreatments.Where(x => x.Sid == Sid).FirstOrDefault().ToString();

           // ViewBag.TList = dbContext.DogTreatments.Where(x => x.Sid == Sid).ToList();
            return PartialView("DisplayTreatments", treat);
        }

View page:

@Html.Partial("~/Views/Shared/DisplayTreatments.cshtml")

Partial view:

@model string

@{
    Layout = null;
}

@Model
John
  • 11
  • 2
  • 1
    Does this answer your question? [How can I pass parameters to a partial view in mvc 4](https://stackoverflow.com/questions/20799658/how-can-i-pass-parameters-to-a-partial-view-in-mvc-4) – Hamed Moghadasi Feb 22 '20 at 19:44
  • @HamedMoghadasi i tried but i got as an output "my_app.Models.DogTreatments" and i cant see the reason – John Feb 22 '20 at 19:55

0 Answers0