0

How can I string concatenate in ASPX view engine? I want to use my variable in generating ids dynamically (in below example, allow ability to add multiple education details).I want to replace (<%=CurrentEducation%>) with id count. I can easily do this in Razor but not in aspx views. Can you also point me the syntax declarations for <% %> things in aspx view engine please? I can find examples only in razor examples.

<% dim currentEducation = 1 %>
<% for each item As EducationDetailsViewModel in Model.EducationDetails %>
<div class="row">
    <div class="col-md-11">
        <div class="row">
            <div class="col-md-3">
                <%= Html.LabelFor(Function(x) item.Educationlevel, New With {.class = "control-label" + "test", .id="EducationDetails_(<%=CurrentEducation%>)_EducationLevel"})%><span class="text-danger">*</span>
                <%= Html.TextBoxFor(Function(x) item.Educationlevel,New With{.class="form-control"})%>
            </div>
            <div class="col-md-4">
                <%= Html.LabelFor(Function(x) item.SchoolName, New With {.class = "control-label"})%><span class="text-danger">*</span>
                <%= Html.TextBoxFor(Function(x) item.SchoolName,New With{.class="form-control"})%>
            </div>
            <div class="col-md-3">
                <%= Html.LabelFor(Function(x) item.YearsAttended, New With {.class = "control-label"})%>
                <%= Html.TextBoxFor(Function(x) item.YearsAttended,New With{.class="form-control"})%>
            </div>
            <div class="col-md-2">
                <%= Html.LabelFor(Function(x) item.IsGraduated, New With {.class = "control-label"})%>
                <%= Html.RadioButtonFor(Function(x) item.isGraduated, False, new with {.style="width:auto"})%>No:
                <%= Html.RadioButtonFor(Function(x) item.isGraduated, True, new with {.style="width:auto"})%>Yes:
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <%= Html.LabelFor(Function(x) item.AreaOfStudy, New With {.class = "control-label"})%>
                <div class="">
                    <%= Html.TextBoxFor(Function(x) item.AreaOfStudy,New With{.class="form-control"})%>
                </div>
            </div>
        </div>
        <br />
    </div>
    <div class="col-md-1">
        <span class="text-danger">X</span>
    </div>
</div>
<% currentEducation = currentEducation + 1 %>
<% next %>
Kalyan
  • 307
  • 2
  • 14
  • 1
    Your taking the wrong approach (at it will never work). Refer [this answer](http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times-data-to-controller/28081308#28081308) for options (and changing the `id` attribute has nothing to do with binding to a model - its the `name` attribute that matters –  Oct 07 '16 at 04:26
  • But if your not dynamically adding or deleting items in the view (just editing existing items), then you simply use an `for` loop or custom `EditorTemplate` (refer [this answer](http://stackoverflow.com/questions/30094047/html-table-to-ado-net-datatable/30094943#30094943)) –  Oct 07 '16 at 04:52
  • I'm adding items dynamically. I'll check attached link and will get back to you. – Kalyan Oct 07 '16 at 14:12

0 Answers0