Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
5
Reply
How set value of DropDown after getting the list
Bryan Gomez
Nov 19 2017 10:57 PM
181
Reply
I need to set value of the dropdown after getting the list for dataset. But I'm having an error of:
The ViewData item that has the key 'txtCustomer' is of type 'System.String' but must be of type 'IEnumerable<SelectListItem>'
Here's my Controller:
wmsSR =
new
WMSSOFT_WCF_Service.WMSSOFT_InterfaceClient();
dsl =
new
DataSet();
dsO =
new
DataSet();
a =
"GetSRMCustomers"
;
b =
string
.Empty;
//b = wmsSR.fCallWMSSOFTService(a, null, ref dsl, ref dsO);
b = wmsSR.fCallWMSSOFTService(a,
""
,
ref
dsl,
ref
dsO);
if
(b ==
"OK ~~"
)
{
if
(dsO.Tables[0].Rows.Count >= 0)
{
List<SelectListItem> item =
new
List<SelectListItem>();
for
(
int
i = 0; i < dsO.Tables[0].Rows.Count; i++)
{
item.Add(
new
SelectListItem { Text = dsO.Tables[0].Rows[i][
"NAMECUST"
].ToString(), Value = dsO.Tables[0].Rows[i][
"IDCUST"
].ToString().Replace(
" "
, String.Empty) });
}
ViewBag.txtCustomer = item;
ViewBag.txtCustomer = "ABC ";
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
DataTable in .Net Core looks plain
Service Unavailable HTTP Error 503.