I have thisdropdownlistand no showsdata, I havesomeerrror?
var City = from s in db.City_Office
join c in db.City on s.IdCityOffice equals c.IdCity
select c;
ViewBag.IdCityoffice = new SelectList(City, "IdCity", "NameCity");
are you saying you do have an error or simply asking whether you have an error?
if you are not explicitly getting some compile time or run time error, then you need to debug your code .... use the debugger* to check values, for example, if your s.IdCityOffice does not equal c.IdCity then zero records will be selected.
also, you need to look at your data as stored in your database to determine what data you actually have stored.
search videos at Google with debug visual studio 2010
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
var City = from s in db.City_Office
join c in db.City on s.IdCityOffice equals c.IdCity
select c;
var list= City.ToList();
if(list.Count == 0)
return Content(" there is no city- look into the database!")
luisvilla
Member
8 Points
7 Posts
Dropdownlist no show data
Mar 25, 2012 02:33 AM|LINK
hello friends
I have this dropdownlist and no shows data, I have some errror?
var City = from s in db.City_Office join c in db.City on s.IdCityOffice equals c.IdCity select c; ViewBag.IdCityoffice = new SelectList(City, "IdCity", "NameCity");gerrylowry
All-Star
20515 Points
5713 Posts
Re: Dropdownlist no show data
Mar 25, 2012 03:12 AM|LINK
@ luisvilla
are you saying you do have an error or simply asking whether you have an error?
if you are not explicitly getting some compile time or run time error, then you need to debug your code .... use the debugger* to check values, for example, if your s.IdCityOffice does not equal c.IdCity then zero records will be selected.
also, you need to look at your data as stored in your database to determine what data you actually have stored.
g.
* walking your code with your debugger:
video, c. 8 minutes: http://msdn.microsoft.com/en-ca/vstudio/ee672313.aspx
"How Do I: Step with The Debugger in Visual Studio?"
Debugging: http://lmgtfy.com/?q=debug+visual+studio+2010
example: http://www.codeproject.com/KB/cs/MasteringInDebugging.aspx
videos: http://www.youtube.com/watch?v=z5gBIizwsY0
search videos at Google with debug visual studio 2010
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: Dropdownlist no show data
Mar 25, 2012 05:39 AM|LINK
var City = from s in db.City_Office join c in db.City on s.IdCityOffice equals c.IdCity select c; var list= City.ToList(); if(list.Count == 0) return Content(" there is no city- look into the database!")ViewBag.IdCityoffice = new SelectList(list, "IdCity", "NameCity");