0

Below is my partial view call:

 <div id="div-reviewgrid">

                        @Html.Partial("_ReviewList", ViewBag.RewiewLists as List<Pollit.Data.Review>)

                    </div>

this is my partial view inside shared folder under Partial:

@using Pollit.Data;

@{
    List<Review> reviewList = ViewBag.RewiewLists;
}

<br /><br />

@if (reviewList != null)
{
    foreach (var review in reviewList)
    {
        <div class="col-lg-12">
            <div id="@review.Id">
                <div class="col-lg-1 col-md-1 col-xs-12 col-sm-12">
                    @if (review.Rating != null)
                    {
                        <img src="/images/ratings/@review.Rating.Number-bars.png" class="pull-left" style="max-height: 50px; max-width: 50px; margin-left: 30px" />
                    }
                </div>
                <div class="col-lg-11 col-md-11 col-xs-12 col-sm-12">
                    <span>@review.Creator.Name &nbsp;@String.Format("{0:d}", review.Created)</span>
                    <br />

                    <h4 class="custum-memphisfontmediumitalic ">@review.Content</h4>
                    @*<input type="submit" value="Like" class="btn btn-info" />
                        <input type="submit" id="click" value="Comment" class="btn btn-info"  />
                         <input type="text" id="comment" placeholder="Enter your comment" class="form-control" />*@
                </div>


            </div>
            <br />
            @if (Request.IsAuthenticated == true)
            {

                if (review.Replys != null)
                {
                    foreach (var reply in review.Replys.OrderBy(c => c.Created))
                    {
                        <div id="reply_@reply.ReplyID" class="col-lg-8 col-md-10 col-xs-12 col-sm-12 col-lg-offset-1 ">



                            <span>Reply By:@reply.Creator.Name &nbsp;@String.Format("{0:d}",  @reply.Created)</span>
                            <br />
                            <h4 class="custum-memphisfontmediumitalic">@reply.ReplyContent</h4>
                        </div>
                    }
                }

                <div class="col-lg-8 col-md-10 col-xs-12 col-sm-12 col-lg-offset-1 form-group ">
                    <input type="text" id="txtReply_@review.Id" placeholder="Enter your reply" class="form-control" />
                </div>
                <div class="col-lg-2 form-group"><div class="demo">
                 <a href= "SubmitReply(@review.Id); return false;" onclick="SubmitReply(@review.Id); return false;" class="pull-right">  Reply</a>
                    <img src="/Images/Comment rate up.png" class="img-responsive" width="40px" ><img src="/Images/Comment rate down.png" class="img-responsive" width="40px" ></div>
                </div>
            }
        </div>
    }
}




<br /><br />

Above is my partial view code so guys let me know if I am doing something wrong. Please help me. Thanks in advance for help

vishu minhas
  • 1,552
  • 1
  • 17
  • 30
  • 1
    did you tried render partial or renderaction ?? – Rush.2707 Jan 06 '17 at 05:47
  • @TetsuyaYamamoto I have apply debugger on it when all list has completed it gives me error after that null exception error in my list there is nothing which are coming null and I have apply check for null objects – vishu minhas Jan 06 '17 at 06:09

1 Answers1

0

when you are calling your partial view the way you have written its wrong. each time you call it the new model is generating and your model goes empty`

@Html.Partial("_ReviewList", ViewBag.RewiewLists as List<Pollit.Data.Review>)

write Model instead of ViewBag.RewiewLists as List<Pollit.Data.Review>

Rush.2707
  • 622
  • 10
  • 26