cnetworks
cnetworks
CC#
Created by cnetworks on 3/1/2023 in #help
❔ Httppost Edit Action Update error
my httppost edit action does not store the form values.Shows an Update Sql exception regarding Country checkbox saving. here is the view for Country checkboxes in Edit.cshtml: @foreach(var country in new List<string> { "India", "America", "Australia", "China" }) { <input type="checkbox" value="@country" id="@country" @(Model.Country.Contains(@country) ? "checked" : "")/>@country <br/> }

<span asp-validation-for="Country" class="text-danger"></span> </div> here is my httppost edit action method: [HttpPost] [ValidateAntiForgeryToken] public IActionResult Edit(int id, RegistTable registration, IFormFile ProfileImage) { string wwwRootPath = _hostEnvironment.WebRootPath; if (id != registration.Id) { return NotFound(); } if (ModelState.IsValid) { // Get the selected country values from the form string[] countryValues = Request.Form["Country"]; var countries = string.Join(",", countryValues); registration.Country = countries; var fileName = Path.GetFileName(ProfileImage.FileName); var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Images", fileName); using (var stream = new FileStream(path, FileMode.Create)) { ProfileImage.CopyTo(stream); } registration.ProfileImage = fileName; } try { _context.Update(registration); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { return NotFound(); } return RedirectToAction(nameof(Index);
2 replies
CC#
Created by cnetworks on 2/27/2023 in #help
❔ Need help in dynamically binding checkbox values in Edit View
2 replies
CC#
Created by cnetworks on 2/26/2023 in #help
❔ CRud in .net core mvc Image file return as null from view to controller
I am doing crud of registration which includes submitting and dynamically retrieving all kinds of ui control like checkboxes dropdownbox text field and image file. Created table in db and scaffolded the model. And I wrote the action methods in controller.But no loading in page.In create submitting method, modelstate.IsValid is false. I have 5 field Id(pk,identity ) Name Email Gender(dropdown) Mobile Country(checkboxes multiple selections) ProfileImage(Image file) I have pasted code MY Views https://paste.mod.gg/zbtemoilfwiw/0 my action https://paste.mod.gg/rmuneguvbize/0 Not load any data in Index and create view not submitting to controller pls help!
7 replies
CC#
Created by cnetworks on 12/2/2022 in #help
❔ How can I save a status of chechbox to a db
Hi I have a table and mcv . In view The data is like below Name Company Action Max viaTech checked(checkbox) Wizou viaTech unchecked(chbox) Export to csv(one button) If I click the button all the selected values from above table should be exported to csv. How I should I achieve this. Please Help.
10 replies
CC#
Created by cnetworks on 9/7/2022 in #help
How to save Checboxes values into single column?
I have a view which has a few checkboxes in mvc. i designed them in html inside view. Now I require to save the selected values of checkboxes into a single column of a table. If there are multiple checbox values, I need to save values with comma separator in that column. Please help
31 replies
CC#
Created by cnetworks on 8/29/2022 in #help
Help recquired please! I got stuck at using ui controls like dropdowns and radio buttons im .net cor
Hi, I got stuck in using ui such as Drop-down list and radio buttons for binding data from db and to push to database as well. I am confused to pick some best way to do this. Does anyone point some resources or pdfs please?
56 replies