Dynamically Arrange Bootstrap Column Horizontally in Razor

@{
    int columnCount = 1;
    int contactSerialNo = 0;
}

@foreach (var contact in ViewBag.ContactInfo.Rows)
    {
        contactSerialNo++;
        if (columnCount==1)
        {
           @:<div class="row-fluid">
        }

        <div class="span3">
            <div class="block well">
                <div class="body">
                    <h4>@contactSerialNo.ToString(). @contact["ContactName"].ToString()

                        @if (contact["CallStatusId"].Equals(DBNull.Value))
                        {
                             //Something
                        }
                        else
                        {
                            int callStatusId = contact["CallStatusId"];
                            switch (callStatusId)
                            {
                                case 1:
                                    @:<img src="@(ViewBag.Url)Assets/Icon.png" />
                                    break;
                            }
                        }

                        @if (Convert.ToBoolean(contact["PTR"]) == true)
                        {
                            @:<img src="@(ViewBag.Url)Assets/lighter.png" />
                        }

                    </h4> <br />
                    Son of @contact["FatherName"].ToString(). <br />
                </div>
            </div>
        </div>

        if (columnCount == 4)
        {
             @:</div>
             columnCount = 1;
        }
        else
        {
            columnCount++;
        }
    }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s