Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
How to pass model data from dynamic bind cshtml mvc4
Mani Kandan
Jan 21 2017 4:29 AM
318
Reply
Hello everyone,
I have bind list of model data. After I want pass to controller. But the controller model object showing null value. How can I solve this?
@model IEnumerable
<
Reboxwebapp.Models.ViewModel.ProductItemsVM
>
@foreach (var item in Model)
{
if (
item.AttributeControlType
== "textbox")
{
<
tr
>
<
td
>
@Html.TextBox("AttributeName", item.AttributeName ?? " ")
</
td
>
<
td
>
@Html.TextBox("txtValidValues", item.ValidValues ?? " ", new {
maxlength
=
item
.AttributeMaxLength ?? 0 })
</
td
>
</
tr
>
}
else if (
item.AttributeControlType
== "DropDownList")
{
<
tr
>
<
td
>
@Html.TextBox("AttributeName", item.AttributeName ?? " ")
</
td
>
<
td
>
@Html.DropDownList("ddlValidValues", new SelectList(item.ValidValues.Split(new char[] { ',' })), new {
style
=
"height: 20px;"
,
size
=
item
.AttributeMaxLength ?? 0 })
</
td
>
</
tr
>
}
else if (
item.AttributeControlType
== "checkbox")
{
<
tr
>
<
td
>
@Html.TextBox("AttributeName", item.AttributeName ?? " ")
</
td
>
<
td
>
<
ul
>
<
li
>
<
input
type
=
"checkbox"
id
=
"chkValidValue"
checked
/>
</
li
>
@item.ValidValues
<
li
>
</
ul
>
</
td
>
</
tr
>
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
pdf file content with searching and highlight
Responsive Dynamic Menu bar in asp.net