I have an app for creating Exams. After creating a new question I would like to pass the question_id parameter to the questions_choices create action. I have created a list of questions choices to do 4 at a time (A, B, C, & D) in the action. I am having difficultly in passing the question_id into the list.
Controller:
public ActionResult CreateNewChoice(int? id)
{
var questions_choices = new List<questions_choices>();
for (int i = 0; i < 4; i++)
{
questions_choices.Add(new questions_choices());
}
return View(questions_choices);
}
I would like to implement something like this within the list but a little confused how.
questions_choices questions_choices = new questions_choices();
questions_choices.questions_id = id;
Model
public partial class questions_choices
{
public long questions_choices_id { get; set; }
public Nullable<int> questions_id { get; set; }
public string questions_choices_value { get; set; }
public string questions_choices_string { get; set; }
}
If a put the two together I have issues with the variable being declared twice.