TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
zeeshan akram
1.4k
325
18.2k
Selected value is not fill in Dropdown list c# mvc
Apr 4 2020 4:17 AM
Hi, I want to edit my product so I have a three dropdown when I click Edit Button product load and Run this function Edit Product data load in result variable but not shown on the front end. I have shared the result of data in the image. a kindly expert can you tell me where I am wrong.
Model
public
class
ProductViewModel
{
public
Product listProducts =
new
Product();
public
List
listProductDetails =
new
List
();
}
Function c#
public
ActionResult EditProduct(
int
id)
{
List
PTlist = _IproductType.PTList();
ViewBag.Ptlist =
new
SelectList(PTlist,
"PType_ID"
,
"P_Name"
);
//Product Color List
List
pColorList = _IProductColor.PColorlist();
ViewBag.pColor_List =
new
SelectList(pColorList,
"C_ID"
,
"C_Name_OR_Code"
);
List
pSizeList = _ISize.pSizeList();
ViewBag.pSizeLists =
new
SelectList(pSizeList,
"S_ID"
,
"S_Size"
);
var result = _IProducts.GetProductByID(id);
return
View(result);
}
Result
view
<
div
class
=
"form-group"
>
<
label
class
=
"control-label col-lg-3"
>
<
span
data-toggle
=
"tooltip"
class
=
"label-tooltip"
data-original-title
=
"Product type"
>
Product Category
</
span
>
</
label
>
<
div
class
=
"col-lg-9"
>
<
div
class
=
"col-sm-9 controls"
>
@if (ViewBag.Ptlist != null)
{
@Html.DropDownListFor(
m
=
>
m.listProducts.PType_ID, ViewBag.Ptlist as SelectList, "Choose Product Category", new { @
class
=
""
, @
id
=
"PTypeID"
})
}
</
div
>
</
div
>
</
div
>
<
div
class
=
"form-group"
>
<
label
class
=
"control-label col-lg-3"
>
<
span
data-toggle
=
"tooltip"
class
=
"label-tooltip"
data-original-title
=
"Product type"
>
Product Color
</
span
>
</
label
>
<
div
class
=
"col-lg-9"
>
<
div
class
=
"col-sm-9 controls"
>
@if (ViewBag.pColor_List != null)
{
@Html.DropDownListFor(
m
=
>
m.listProducts.P_Color_ID, ViewBag.pColor_List as SelectList, "Choose Product Color", new { @
class
=
""
, @
id
=
"PColorID"
})
}
</
div
>
</
div
>
</
div
>
<
div
class
=
"form-group"
>
<
label
class
=
"control-label col-lg-3"
>
<
span
data-toggle
=
"tooltip"
class
=
"label-tooltip"
data-original-title
=
"Product type"
>
Product Size
</
span
>
</
label
>
<
div
class
=
"col-lg-9"
>
<
div
class
=
"col-sm-9 controls"
>
@if (ViewBag.pSizeLists != null)
{
@Html.DropDownListFor(
m
=
>
m.listProducts.P_SizeID, ViewBag.pSizeLists as SelectList, "Choose Product Size", new { @
class
=
""
, @
id
=
"PSizeID"
})
}
</
div
>
</
div
>
</
div
>
Reply
Answers (
2
)
streaming video in vlc
C code of Assemble code?