Topic:   How to Bind RadioButton List created by jQuery in ASP.NET MVC 5
Oct 24, 2020 05:10 2 Replies 482 Views RITA
public class MyModelClass()
{

    public MyModelClass()
    {

    }

    public List DataCollectionList { get; set; }

}

public class MyClass
{

    public MyClass()
    {

    }

    public string CurrentValue { get; set; }

    public bool IsChecked { get; set; } 

}
Prev Next
Topic Replies (2)
  1. 1
    idnkx user

    NAIDU

    Index










    @section scripts {

    $('#radios').append($('').attr('type', 'radio').attr('name', '[0].Name').attr('value', 'red')).append(' red').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[0].Name').attr('value', 'green')).append(' green').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', 'Color[0].Name').attr('value', 'blue')).append(' blue').append($(''));

    $('#radios').append($(''));

    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'red')).append(' red').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'green')).append(' green').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'blue')).append(' blue').append($(''));

    public class Color
    {
    public string Name { get; set; }
    }
    public ActionResult Index(List model)
    {
    return Json(model);
    }

    1
    idnkx user

    PARTH

    You can see below sample code -

    Index










    @section scripts {

    $('#radios').append($('').attr('type', 'radio').attr('name', '[0].Name').attr('value', 'red')).append(' red').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[0].Name').attr('value', 'green')).append(' green').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', 'Color[0].Name').attr('value', 'blue')).append(' blue').append($(''));

    $('#radios').append($(''));

    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'red')).append(' red').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'green')).append(' green').append($(''));
    $('#radios').append($('').attr('type', 'radio').attr('name', '[1].Name').attr('value', 'blue')).append(' blue').append($(''));


    public class Color
    {
    public string Name { get; set; }
    }
    public ActionResult Index(List model)
    {
    return Json(model);
    }

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect