Home How to write razor query to display two fields side by side?
Reply: 0

How to write razor query to display two fields side by side?

user1768
1#
user1768 Published in June 20, 2018, 1:29 am

I am dynamically generating the fields using a foreach loop. I have several conditions on rendering those fields. There is one condition where on it being true, there are two fields that should be rendered side by side on the same row. I tried every possible approach but it isn't getting rendered as I want. I can't use <div class="form-group"> of as it will display the fields on separate lines. So, how should I write the razor query combined with bootstrap's code such that I have two fields side by side. Here is my current code:

@foreach (var d in data)
{
    if (Condition1)
    {
        <div class="form-group">

            <label class="col-sm-3 control-label">
                Text 1
            </label>
            <div class="col-sm-8">

                @Html.TextBox("Box1")

            </div>

        </div>
    }
    else if(Condition 2)
    {
        <div class="form-group">
            <label class="col-sm-3 control-label">
                Text 2
            </label>

            <div class="col-sm-8">

                @Html.TextBox("Box2")

            </div>
        </div>
    }

     else if(Condition3)
     {
        <form class="form-inline">
            <label class="required col-sm-3 control-label">
                @*Horsepower and RPM*@
            </label>
            <div class="col-sm-2">
                @{
                    @Html.TextBox("Box2")
                }
            </div>
        </form>       
     }
}

Condition 3 is where I want to render those 2 fields This is my current state: check position of horsepower or rpm

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320471 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO