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, "", 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 ";
- }
- }