2

I have Course, Offered Course , Course Registration table ,Section Table in my project I want to implement Course Registration system of each user.enter image description here this is my database diagram of the project.enter image description here I want to implement this feature like this . I don't implement this features of

   class time . public class Course
{
    [Key]

    public int CourseId { get; set; }
    [Required]
    public string Name { get; set; }
    public string Code { get; set; }
    public string Credit { get; set; }
    public DateTime RegDate { get; set; }

    public string PreCourse { get; set; }
    public int DepartmentId { get; set; }
    [ForeignKey("DepartmentId")]
    public virtual Department Department { get; set; }
    public virtual ICollection<OfferedCourse> OfferedCourses { get; set; }

}

this is my course model,

   public class Department
   {
    [Key]
    public int DepartmentId { get; set; }
    [Required]
    public string Name { get; set; }
    [Required]
    public string Code { get; set; }
    public virtual ICollection<ApplicationUser> ApplicationUsers { get; set; }
    public virtual ICollection<Course> Courses { get; set; }
}

this is my department model,

     public class OfferedCourse
{
    [Key]
    public int OfferedCourseId { get; set; }
    public int Capacity { get; set; }
    public bool Status { get; set; }
    public int CourseId { get; set; }
    [ForeignKey("CourseId")]
    public virtual Course Course { get; set; }
    public string TeacherId { get; set; }
    [ForeignKey("TeacherId")]
    public virtual ApplicationUser ApplicationUser { get; set; }
    public int SectionId { get; set; }
    [ForeignKey("SectionId")]
    public virtual Section Section { get; set; }
    public int SemesterId { get; set; }
    [ForeignKey("SemesterId")]
    public virtual Semester Semester { get; set; }
    public virtual ICollection<CourseRegistration> CourseRegistrations { get; set; }

}

this is my offered course for each semester.

     public class Section
{
    [Key]
    public int SectionId { get; set; }

    public string Title { get; set; }



}

this is my section model.In this project, I am using asp.net identity framework for manage user like teacher, student. But have tried many ways to manage the radio button in Course Registration View . How Can I implement this feature because I have different type of data like section and course name how can I handle this

Cœur
  • 37,241
  • 25
  • 195
  • 267
Hoque MD Zahidul
  • 10,560
  • 2
  • 37
  • 40
  • You image shows checkboxes, not radio buttons. Assuming you do want to select multiple courses as suggested by your model, refer [this answer](http://stackoverflow.com/questions/29542107/pass-list-of-checkboxes-into-view-and-pull-out-ienumerable/29554416#29554416) for a typical example of the view models and view –  Dec 12 '16 at 23:26
  • yeah I need radio button.. how can I do this....I need a view model I think but how can I implement – Hoque MD Zahidul Dec 13 '16 at 02:48
  • Sorry, impossible to understand from what you have shown. Is "Bachelor of Science ...." your `Section.Title` property? Are the 3 items under it the `OfferedCourses` for that `Section` DO you only want to select one of those 3? –  Dec 13 '16 at 03:25
  • each aubject have many sections like A,B or C,d. I want to show in view like this : Algorithm and al section of algorir using radio button – Hoque MD Zahidul Dec 13 '16 at 03:28

2 Answers2

0

If you're using mvc razor, you can generate your RadioButtons with a foreach. something like this:

//HTML code here
@foreach (var offeredCourse in Model.OfferedCourses)
{       
    @Html.RadioButton(offeredCourse.OfferedCourseId.ToString(), offeredCourse.ID)          
}
//HTML code here

but I'm not sure which model you're using. Please paste your Course Registration View code to be more specific with this answer

Orion_Dev
  • 29
  • 4
  • but section is another table – Hoque MD Zahidul Dec 12 '16 at 18:00
  • each subject has many section....I need generate radio button for each section for individual subject – Hoque MD Zahidul Dec 12 '16 at 18:01
  • I don't write any course registration view model yet because I don't understand what need to do. but course registration view model have these property studentId, offeredcourseId.. because I can find the section using offeredCourseId. – Hoque MD Zahidul Dec 13 '16 at 02:13
  • @HoqueMDZahidul Can you copy and paste your view code? (cshtml file) to verify which model you're using and to see how you're trying to generate these radiobuttons – Orion_Dev Dec 13 '16 at 13:24
-1

I think its easy to use radio buttons group... See this link http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio

but for registration page you should use if else code in javascript to handle your request:

<script>
$('#register-btn').click(function () {
    var regType = 0;
    if ($('#radio1').is(":checked")) {
        regType = 1;
    }
    if ($('#radio2').is(":checked")) {
        regType = 2;
    }
    if ($('#radio3').is(":checked")) {
        regType = 3;
    }
    $.ajax({
        type: "POST",
        url: "/Registration/reg_Ajax",
        contentType: "application/json; charset=utf-8",
        data: '{type: "' + regType + '"}',
        dataType: "text",
        success: function (response) {
            alert(response);
        },
        failure: function (response) {
            alert("fail");
        },
        error: function (request, status, error) {
            alert('error');
        }
    });
});

view:

<form> <input type="radio" name="reg" value="male" id="radio1" checked> Male<br> <input type="radio" name="reg" value="female" id="radio2"> Female<br> <input type="radio" name="reg" value="other" id="radio3"> Other <br> <input type="Button" value="Register" id="register-btn"> </form>