Radiobuttonfor default all unchecked












0















I have a model as below



public class TestModel
{
public string SE { get; set; }
}



Then i have an interface and implementing class, Businesslogic class as below.



public interface ITest
{
List<TestModel> SE();
}



 public class Test : ITest
{
public List<TestModel> SE()
{
SEBLL B=new SEBLL();
List<TestModel> lstSeries = new List<TestModel>();
lstSeries = B.SE();
return lstSeries;
}
}


my Business logic class where i bind data from database or sometimes manually



public class SEBLL
{
public List<TestModel> SE()
{
List<TestModel> e = new List<TestModel>();
e.Add(new TestModel{ SE = "A" });
e.Add(new TestModel{ SE = "B" });
return e;
}
}


my controller



 public ActionResult Index()
{
ITest s = new Test();
List<TestModel> lstSeries = s.SE();
return View(lstSeries);

}


Finally here is the stronly typed view.



@model IEnumerable<TestModel>    
foreach (var item in Model)
{
<div>
<label>
@Html.RadioButtonFor(m => item.SE, item.SE, new { @id = "SE", @class = "radio" })
SE @item.series
</label>
</div>
}


I need both of the Radiobuttons to be unchecked intially.



I am bit new to MVC, radiobutton list is populated with 2 values, but always anyone value is being selected when view initially loads. i tried setting checked html property but that did not help.



please let me know where am i going wrong in the whole process.
Correct me with the process too if i am following wrong flow.










share|improve this question

























  • Could you please correct the code, because I am not able to see class TestBModel model.

    – Satish Pai
    Nov 18 '18 at 14:34











  • Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

    – Hussain
    Nov 18 '18 at 15:33













  • Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

    – user3559349
    Nov 18 '18 at 21:12
















0















I have a model as below



public class TestModel
{
public string SE { get; set; }
}



Then i have an interface and implementing class, Businesslogic class as below.



public interface ITest
{
List<TestModel> SE();
}



 public class Test : ITest
{
public List<TestModel> SE()
{
SEBLL B=new SEBLL();
List<TestModel> lstSeries = new List<TestModel>();
lstSeries = B.SE();
return lstSeries;
}
}


my Business logic class where i bind data from database or sometimes manually



public class SEBLL
{
public List<TestModel> SE()
{
List<TestModel> e = new List<TestModel>();
e.Add(new TestModel{ SE = "A" });
e.Add(new TestModel{ SE = "B" });
return e;
}
}


my controller



 public ActionResult Index()
{
ITest s = new Test();
List<TestModel> lstSeries = s.SE();
return View(lstSeries);

}


Finally here is the stronly typed view.



@model IEnumerable<TestModel>    
foreach (var item in Model)
{
<div>
<label>
@Html.RadioButtonFor(m => item.SE, item.SE, new { @id = "SE", @class = "radio" })
SE @item.series
</label>
</div>
}


I need both of the Radiobuttons to be unchecked intially.



I am bit new to MVC, radiobutton list is populated with 2 values, but always anyone value is being selected when view initially loads. i tried setting checked html property but that did not help.



please let me know where am i going wrong in the whole process.
Correct me with the process too if i am following wrong flow.










share|improve this question

























  • Could you please correct the code, because I am not able to see class TestBModel model.

    – Satish Pai
    Nov 18 '18 at 14:34











  • Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

    – Hussain
    Nov 18 '18 at 15:33













  • Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

    – user3559349
    Nov 18 '18 at 21:12














0












0








0








I have a model as below



public class TestModel
{
public string SE { get; set; }
}



Then i have an interface and implementing class, Businesslogic class as below.



public interface ITest
{
List<TestModel> SE();
}



 public class Test : ITest
{
public List<TestModel> SE()
{
SEBLL B=new SEBLL();
List<TestModel> lstSeries = new List<TestModel>();
lstSeries = B.SE();
return lstSeries;
}
}


my Business logic class where i bind data from database or sometimes manually



public class SEBLL
{
public List<TestModel> SE()
{
List<TestModel> e = new List<TestModel>();
e.Add(new TestModel{ SE = "A" });
e.Add(new TestModel{ SE = "B" });
return e;
}
}


my controller



 public ActionResult Index()
{
ITest s = new Test();
List<TestModel> lstSeries = s.SE();
return View(lstSeries);

}


Finally here is the stronly typed view.



@model IEnumerable<TestModel>    
foreach (var item in Model)
{
<div>
<label>
@Html.RadioButtonFor(m => item.SE, item.SE, new { @id = "SE", @class = "radio" })
SE @item.series
</label>
</div>
}


I need both of the Radiobuttons to be unchecked intially.



I am bit new to MVC, radiobutton list is populated with 2 values, but always anyone value is being selected when view initially loads. i tried setting checked html property but that did not help.



please let me know where am i going wrong in the whole process.
Correct me with the process too if i am following wrong flow.










share|improve this question
















I have a model as below



public class TestModel
{
public string SE { get; set; }
}



Then i have an interface and implementing class, Businesslogic class as below.



public interface ITest
{
List<TestModel> SE();
}



 public class Test : ITest
{
public List<TestModel> SE()
{
SEBLL B=new SEBLL();
List<TestModel> lstSeries = new List<TestModel>();
lstSeries = B.SE();
return lstSeries;
}
}


my Business logic class where i bind data from database or sometimes manually



public class SEBLL
{
public List<TestModel> SE()
{
List<TestModel> e = new List<TestModel>();
e.Add(new TestModel{ SE = "A" });
e.Add(new TestModel{ SE = "B" });
return e;
}
}


my controller



 public ActionResult Index()
{
ITest s = new Test();
List<TestModel> lstSeries = s.SE();
return View(lstSeries);

}


Finally here is the stronly typed view.



@model IEnumerable<TestModel>    
foreach (var item in Model)
{
<div>
<label>
@Html.RadioButtonFor(m => item.SE, item.SE, new { @id = "SE", @class = "radio" })
SE @item.series
</label>
</div>
}


I need both of the Radiobuttons to be unchecked intially.



I am bit new to MVC, radiobutton list is populated with 2 values, but always anyone value is being selected when view initially loads. i tried setting checked html property but that did not help.



please let me know where am i going wrong in the whole process.
Correct me with the process too if i am following wrong flow.







asp.net-mvc razor






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 16:49







Hussain

















asked Nov 18 '18 at 14:00









HussainHussain

105




105













  • Could you please correct the code, because I am not able to see class TestBModel model.

    – Satish Pai
    Nov 18 '18 at 14:34











  • Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

    – Hussain
    Nov 18 '18 at 15:33













  • Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

    – user3559349
    Nov 18 '18 at 21:12



















  • Could you please correct the code, because I am not able to see class TestBModel model.

    – Satish Pai
    Nov 18 '18 at 14:34











  • Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

    – Hussain
    Nov 18 '18 at 15:33













  • Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

    – user3559349
    Nov 18 '18 at 21:12

















Could you please correct the code, because I am not able to see class TestBModel model.

– Satish Pai
Nov 18 '18 at 14:34





Could you please correct the code, because I am not able to see class TestBModel model.

– Satish Pai
Nov 18 '18 at 14:34













Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

– Hussain
Nov 18 '18 at 15:33







Corrected it is just TestModel, please correct me whether the procedure i am following is correct.

– Hussain
Nov 18 '18 at 15:33















Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

– user3559349
Nov 18 '18 at 21:12





Your code makes no sense. You cannot use the same property for the options. You need a model with a (say) string SelectedOption and List<TestModel> Options` and then its foreach (var item in Model.Options) { @Html.RadioButtonFor(m => m.SelectedOption, item.SE, new { id = "", @class = "radio" })

– user3559349
Nov 18 '18 at 21:12












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361703%2fradiobuttonfor-default-all-unchecked%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361703%2fradiobuttonfor-default-all-unchecked%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings