Razor - set flag identifier in foreach loop

I look at the list of suppliers on my page, creating a check box for each of them. I would like each flag to have an identifier like "Vendor1", "Vendor30", where the number is the vendor identifier.

I have it right now:

@foreach (var vendor in Model.Vendors) {
    <input id="@vendor.VendorID" type="checkbox" name="vendors" value="@vendor.VendorID" />
}

But that just gives me a number for an identifier. I want to add a "Provider" to it.

If I do this:

@foreach (var vendor in Model.Vendors) {
    <input id="Vendor@vendor.VendorID" type="checkbox" name="vendors" value="@vendor.VendorID" />
}

Each flag in the list has the identifier " Vendor@vendor.VendorID ".

I do not use @Html.CheckBoxbecause of the hidden field that comes with him, and several other problems that he caused that I did not include in this example.

+5
1

:

<input id="Vendor@(vendor.VendorID)" type="checkbox" name="vendors" value="@vendor.VendorID" />

@Html.CheckBox - , , , , .

.

+13

All Articles