Last post Aug 01, 2019 04:07 PM by john_mm
Member
133 Points
320 Posts
Aug 01, 2019 12:13 PM|john_mm|LINK
Hello ,
I have a [] with 4 parmeters and I would like to display the db parameter and alow the user to select anther one (edit mode)
how ever , the display as select is always the last parameter in the []
I think cod e will explain better
in my controller :
ViewBag.dis = new string[4] { "a", "b", "c", "d" };
in my view
@{var disss = "b"; } //value just to be clear @foreach (var item in (ViewBag.dis)) { if (item == disss) { <li class="radio space"> <label> <input type="radio" asp-for="District" value=@item checked="checked"> @item <i class="fas fa-street-view"></i> </label> </li> } // if (item != Model.District) if (item !=disss) { <li class="radio space"> <label> <input type="radio" asp-for="District" value=@item checked=""> @item <i class="fas fa-street-view"></i> </label> </li> }
what ever the value is the user always view value d as checked how can I show the correct value as checked? Thanks
11 Points
19 Posts
Aug 01, 2019 12:45 PM|Koss86|LINK
<div> @foreach (var item in (ViewBag.dis)) { <div class="form-check"> <input class="form-check-input" type="radio" name="exampleRadios" id='exampleRadios@(item)' value="@item" @(item == disss ? "checked" : "") onchange="alert('@item');"> <label class="form-check-label" for="exampleRadios@(item)"> @item <i class="fas fa-street-view"></i> </label> </div> } </div>
i use bootstrap
All-Star
58474 Points
15798 Posts
Aug 01, 2019 02:04 PM|bruce (sqlwork.com)|LINK
Aug 01, 2019 04:07 PM|john_mm|LINK
Thank you bruce
Member
133 Points
320 Posts
display value as checkedin checkbox from []
Aug 01, 2019 12:13 PM|john_mm|LINK
Hello ,
I have a [] with 4 parmeters and I would like to display the db parameter and alow the user to select anther one (edit mode)
how ever , the display as select is always the last parameter in the []
I think cod e will explain better
in my controller :
ViewBag.dis = new string[4] { "a", "b", "c", "d" };
in my view
what ever the value is the user always view value d as checked how can I show the correct value as checked? Thanks
Member
11 Points
19 Posts
Re: display value as checkedin checkbox from []
Aug 01, 2019 12:45 PM|Koss86|LINK
i use bootstrap
All-Star
58474 Points
15798 Posts
Re: display value as checkedin checkbox from []
Aug 01, 2019 02:04 PM|bruce (sqlwork.com)|LINK
Member
133 Points
320 Posts
Re: display value as checkedin checkbox from []
Aug 01, 2019 04:07 PM|john_mm|LINK
Thank you bruce