سؤال

I have the following code :-

@foreach (var item in Model)
{
    <div class="comment-box">
        <div class="comment-head">
            <div class="comment-name">
                @item.FromUser
            </div>
            <div class="comment-date">
                @item.DaysAgo
            </div>
        </div>
        <div class="comment-content">
            @item.Message
        </div>
    </div>
}

I want to show this by webgrid. But problem is webgrid shows the data in columns, how to do it in div structure.

This is my new code for using webgrid :-

@{ 
    var grid = new WebGrid(Model); 
}
<div>
   @grid.GetHtml()
</div>
هل كانت مفيدة؟

المحلول

The following thing worked for me :-

@{ 
        var grid = new WebGrid(Model); 
 }
    <div>
        @grid.GetHtml(tableStyle: "table-comment",
        columns: grid.Columns(
            grid.Column("", "", @<text><div class="comment-box">
        <div class="comment-head">
            <div class="comment-name">
                @item.FromUser
            </div>
            <div class="comment-date">
                @item.DaysAgo
            </div>
        </div>
        <div class="comment-content">
            @item.Message
        </div>
    </div></text>)))

    </div>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top