I am trying to pass complex object from my view to my controller.
I give the ability to the client to create infinity listBox.
How can I transfer this to the controller?
Here is description:
For every CompanyFeedbackTopic, the client can insert infinite CompanyFeedBackQuestion(Text with int).
I have this objects:
public class CompanyFeedbackTopic
{
/***fields***/
private readonly int m_topicId;
private int m_companyFeedbackId;
private int m_formatFeedbackId;
private int m_percent;
private List<CompanyFeedbackQuestion> m_companyFeedbackQuestionList;
/***constractors***/
public CompanyFeedbackTopic(int topicId, int companyFeedbackId, int formatFeedbackId, int percent,
List<CompanyFeedbackQuestion> companyFeedbackQuestionList)
{
m_topicId = topicId;
m_companyFeedbackId = companyFeedbackId;
m_formatFeedbackId = formatFeedbackId;
m_percent = percent;
m_companyFeedbackQuestionList = companyFeedbackQuestionList;
}
/***get/set***/
public int TopicId
{ get { return m_topicId; } }
public int CompanyFeedbackId
{ get { return m_companyFeedbackId; } set { m_companyFeedbackId = value; }}
public int FormatFeedbackId
{ get { return m_formatFeedbackId; } set { m_formatFeedbackId = value; }}
public int Percent
{ get { return m_percent; } set { m_percent = value; }}
public List<CompanyFeedbackQuestion> CompanyFeedbackQuestionList
{ get { return m_companyFeedbackQuestionList; } set { m_companyFeedbackQuestionList = value; }
}
/***functions***/
}
public class CompanyFeedbackQuestion
{
/***fields***/
private readonly int m_questionId;
private int m_topicId;
private string m_question;
private int m_fieldGradeOptions;
/***constractors***/
public CompanyFeedbackQuestion(int questionId, int topicId, string question, int fieldGradeOptions)
{
m_questionId = questionId;
m_topicId = topicId;
m_question = question;
m_fieldGradeOptions = fieldGradeOptions;
}
/***get/set***/
public int QuestionId
{ get { return m_questionId; } }
public int TopicId
{ get { return m_topicId; } set { m_topicId = value; }}
public string Question
{ get { return m_question; } set { m_question = value; } }
public int FieldGradeOptions
{ get { return m_fieldGradeOptions; } set { m_fieldGradeOptions = value; }}
}
And this is the view:
@using (Html.BeginForm("SubmitNewForm", "ManageFeedback", FormMethod.Post))
{
@Html.Label("Choose feedback type: ")
@Html.DropDownListFor(model => model.SelectedFeedbaclType, Model.FeedbackTypesDic.Select(i => new SelectListItem() { Text = i.Value, Value = i.Key.ToString() }), "---")
<div id="formTable">
@foreach (var item in Model.FormatFeedbackDic)
{
<h4>@item.Value</h4>
<table id="@item.Key">
<tr>
<td class="tableHeader">#</td>
<td class="tableHeader">question</td>
<td class="tableHeader">Grade Options</td>
</tr>
<tr>
<td>1</td>
<td>@Html.TextBox("SS", "", new { style = "width:500px" })</td>
<td>@Html.DropDownList("fieldGradeOptions", Model.GetDropDownList()) </td>
</tr>
</table>
<br />
<button onclick="AddNewRow(@item.Key);">+</button>
<hr />
}
</div>
<br />
<button onclick="SubmitForm();">Create new feedback</button>
}
How can I transfer it to the view?