rosemary

rosemary

  • NA
  • 57
  • 20.2k

Cannot implicitly convert type 'System.Data.DataSet' to 'Sys

Jul 4 2018 6:43 AM
I want to display the 'company added jobs' in a table on the selected index change of country dropdown. but when I pass values in dataset to list,
 
it displays the error 
 
Cannot implicitly convert type 'System.Data.DataSet' to 'System.Collections.Generic.List
 
How can I convert dataset values to list?
 
model class
  1. public class company_add_jobs  
  2. {  
  3. public int pid { getset; }  
  4. public string Job_Name { getset; }  
  5. public string Job_Description { getset; }  
  6. public string Job_Type { getset; }  
  7. public string Qualification { getset; }  
  8. public string Salary { getset; }  
  9. public string Vaccancy { getset; }  
  10. public DataSet display{ getset; }  
  11. //public int cid { get; set; }  
  12. [Display(Name = "Company")]   
  13. public int cid { getset; }   
  14. public string Company_Name { getset; }  
  15. public List listcompany { getset; }   
  16. public IEnumerable companylistitems   
  17. {  
  18. get  
  19. {  
  20. return new SelectList(listcompany, "cid""Company_Name");  
  21. }  
  22. }  
  23. } 
controller.cs
  1. [HttpGet]  
  2. public ActionResult selectcompany()  
  3. {  
  4. company_add_jobs c = new company_add_jobs();  
  5. DataSet dt = db.getcompany();  
  6. c.listcompany = dt;  
  7. c.cid = c.listcompany.First().cid;  
  8. c.Company_Name = c.listcompany.First().Company_Name;  
  9. return View(c);  
  10. }  
  11. [HttpPost]  
  12. public ActionResult selectcompany(company_add_jobs s)  
  13. {  
  14. DataSet dt = db.getcompany();  
  15. s.listcompany = dt;  
  16. var emp = s.listcompany.Where(e => e.cid == s.cid).FirstOrDefault();  
  17. s.cid = emp.cid;  
  18. DataSet ds = db.ddapplyjobs(s);  
  19. s.display = ds;  
  20. return View(s);  
  21. } 
dbconnection.cs
  1. public DataSet getcompany()  
  2. {  
  3. SqlCommand cmd = new SqlCommand("select * from company_regn", con);  
  4. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  5. DataSet dt = new DataSet();  
  6. da.Fill(dt);  
  7. return dt;  
  8. } 

Answers (3)