<div class="row" id="education-seminar-forms-BilgisayarBilgi">
@for (int i = 0; i < Model.tBL_BilgisayarBilgisis.Count; i++)
{
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Program Adı</label>
@Html.EditorFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, new { htmlAttributes = new { @class = "form-control", @Value = "MS Office (Excel)", @readonly = "readonly" } })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Seviye</label>
@Html.DropDownListFor(model => model.tBL_BilgisayarBilgisis[i].seviye, new List<SelectListItem>
{
new SelectListItem { Text = "Orta", Value = "Orta" },
new SelectListItem { Text = "İyi", Value = "İyi" },
new SelectListItem { Text = "İleri", Value = "İleri" }
}, "Seçiniz", new { @class = "form-select" })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].seviye, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Program Adı</label>
@Html.EditorFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, new { htmlAttributes = new { @class = "form-control", @Value = "MS Office (Word)", @readonly = "readonly" } })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Seviye</label>
@Html.DropDownListFor(model => model.tBL_BilgisayarBilgisis[i].seviye, new List<SelectListItem>
{
new SelectListItem { Text = "Orta", Value = "Orta" },
new SelectListItem { Text = "İyi", Value = "İyi" },
new SelectListItem { Text = "İleri", Value = "İleri" }
}, "Seçiniz", new { @class = "form-select" })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].seviye, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Program Adı</label>
@Html.EditorFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, new { htmlAttributes = new { @class = "form-control", @Value = "MS Office (Powerpoint)", @readonly = "readonly" } })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Seviye</label>
@Html.DropDownListFor(model => model.tBL_BilgisayarBilgisis[i].seviye, new List<SelectListItem>
{
new SelectListItem { Text = "Orta", Value = "Orta" },
new SelectListItem { Text = "İyi", Value = "İyi" },
new SelectListItem { Text = "İleri", Value = "İleri" }
}, "Seçiniz", new { @class = "form-select" })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].seviye, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Program Adı</label>
@Html.EditorFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, new { htmlAttributes = new { @class = "form-control", @Value = "MS Office (Outlook)", @readonly = "readonly" } })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].ProgramAdi, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Seviye</label>
@Html.DropDownListFor(model => model.tBL_BilgisayarBilgisis[i].seviye, new List<SelectListItem>
{
new SelectListItem { Text = "Orta", Value = "Orta" },
new SelectListItem { Text = "İyi", Value = "İyi" },
new SelectListItem { Text = "İleri", Value = "İleri" }
}, "Seçiniz", new { @class = "form-select" })
@Html.ValidationMessageFor(model => model.tBL_BilgisayarBilgisis[i].seviye, "", new { @class = "text-danger" })
</div>
</div>
}
<div class="row">
<div class="col-md-12">
<div class="text-end">
<button type="button" class="btn btn-primary" id="add-more-BilgisayarBilgi" style=" align-items: flex-start; display: block; padding: 10px !important; ">Bilgisayar bilgisi Ekle</button>
</div>
</div>
</div>
<script>
$(document).ready(function () {
var maxFields = 55;
var addButton = $('#add-more-BilgisayarBilgi');
var wrapper = $('#education-seminar-forms-BilgisayarBilgi'); // Container for education sections
var formCount = 4;
$(addButton).click(function () {
if (formCount < maxFields) {
formCount++; // Increase the form count
var newEducationSection = `
<div class="row BilgisayarBilgi-section">
<div class="col-xl-6 mb-6">
<div class="input-block mb-6">
<label class="col-form-label">Program Adı</label>
<input type="text" name="tBL_BilgisayarBilgisis[${formCount - 1}].ProgramAdi" class="form-control" />
</div>
</div>
<div class="col-xl-5 mb-5">
<div class="input-block mb-6">
<label class="col-form-label">Seviye</label>
<select class="form-select" name="tBL_BilgisayarBilgisis[${formCount - 1}].Seviye">
<option value="Orta">Orta</option>
<option value="İyi">İyi</option>
<option value="İleri">İleri</option>
</select>
<span class="text-danger field-validation-valid" data-valmsg-for="tBL_BilgisayarBilgisis[${formCount - 1}].Seviye" data-valmsg-replace="true"></span>
</div>
</div>
<div class="col-xl-1 text-end align-self-center">
<button type="button" class="btn btn-danger remove-button" style=" align-items: flex-start; display: block; padding: 10px !important;">X</button>
</div>
</div>
`;
$(newEducationSection).insertBefore(addButton.parent());
}
});
// Handle the click event of the remove button
$(wrapper).on('click', '.remove-button', function () {
$(this).closest('.BilgisayarBilgi-section').remove();
formCount--; // Decrease the form count
});
});
</script>
</div>
for (int i = 0; i < csbasvurularr.tBL_BilgisayarBilgisis.Count; i++)
{
var ProgramAdi = csbasvurularr.tBL_BilgisayarBilgisis[i].ProgramAdi;
var Seviye = csbasvurularr.tBL_BilgisayarBilgisis[i].seviye;
if (!string.IsNullOrEmpty(ProgramAdi) && !string.IsNullOrEmpty(Seviye))
{
TBL_BilgisayarBilgisi tBL_BilgisayarBilgisi = new TBL_BilgisayarBilgisi();
tBL_BilgisayarBilgisi.GenelBilgiid = newlyCreatedId;
tBL_BilgisayarBilgisi.ProgramAdi = ProgramAdi;
tBL_BilgisayarBilgisi.seviye = Seviye;
tBL_BilgisayarBilgisi.isDelete = false;
db.TBL_BilgisayarBilgisi.Add(tBL_BilgisayarBilgisi);
}
}
Hello everyone, I have a problem, I ask for your help, there are 4 fixed data in for here, the user is this
has to fill in the data, but the user can also add it with the script himself, now the error starts from here when saving to the database only for
It saves the first data in the loop and what the user adds with the script, that is, it passes the other 3 data in the for, I wonder how to solve this problem.
how can I make the user save the first 4 data fixed so I can solve it