I am using C# and have a login session.
The site will only view the news (nyhet) that the journalist have written. (It's a site where the journalist can edit the news)
protected void FyllNyhetDropDownList()
{
using (NyhetAdminDataContext dbKobling = new NyhetAdminDataContext())
{
Journalist brukernavn = (from journalist in dbKobling.Journalists
where journalist.JournalistId = Convert.ToInt16(Session["bruker"].ToString())
select journalist).SingleOrDefault();
List<Nyhet> nyhetliste = (from nyhet in dbKobling.Nyhets
select nyhet).ToList();
if (nyhetliste.Count() > 0)
{
NyhetDropDowwnList.DataTextField = "Tittel";
NyhetDropDowwnList.DataValueField = "NyhetId";
NyhetDropDowwnList.DataSource = nyhetliste;
NyhetDropDowwnList.DataBind();
}
}
}
It's here all go wrong. Can anyone help?
where journalist.JournalistId = Convert.ToInt16(Session["bruker"].ToString())
I get the error message
Cannot implicitly convert type 'int' to 'bool'
Thanks for any help!
whereclause requires a conditional statement. You're using the=assignment operator and not the==comparison operator. I would also caution you against the use ofInt16if you need values beyond2^16for theJournalistId.