2017-01-06 19 views
0

以下は部分的ビューをレンダリング私の部分図の呼び出しです:オブジェクト参照が

<div id="div-reviewgrid"> 

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

        </div> 

が、これは一部の下で、共有フォルダ内の私の部分図である:上記

@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="[email protected]" 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="[email protected]" 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 /> 

です私の部分的な部分のコードなので、私は何か間違っているかどうか知らせてくれます。私を助けてください。ヘルプの事前のおかげで、あなたが間違って書いた方法でパーシャルビューを呼び出しているときに

+1

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

書き込みModelをempty'行きます? –

+0

@ TetsuyaYamamotoすべてのリストが完成したらデバッガを適用しました。リストのnull例外エラーの後にエラーが表示されます。nullになるものは何もなく、nullオブジェクトをチェックしています。 –

答えて

0

あなたが部分的またはrenderactionレンダリングしようとしたんでしたあなたはそれを呼び出すたびに新しいモデルが生成されると、あなたのモデルが代わりにViewBag.RewiewLists as List<Pollit.Data.Review>

関連する問題