Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

left hand side of an assignment must be a variable [closed]

Tags:

c#

asp.net

linq

Trying to put an integer data from database(Linq to sql) into a label getting this error exception:

left-hand side of an assignment must be a variable property or indexer

Code:

protected void Page_Load(object sender, EventArgs e)
{
   DataClassesDataContext data = new DataClassesDataContext();

   var visit = (from v in data.SeeSites where v.Date == todaydate select v).FirstOrDefault();
   int seennow = visit.See; // On This line I can put data in seenow variable, no problem

   Convert.ToInt64(lblSeeNow.Text) = visit.See;   // exception error appears here
}
like image 714
farhang67 Avatar asked Mar 22 '23 18:03

farhang67


1 Answers

Try:

if (visit.See != null) {
    lblSeeNow.Text = visit.See.ToString();
}

You cannot assign something to a function result. In your case lblSeeNow.Text is of type String hence usage of ToString(); method of your Int value.

like image 145
Yuriy Galanter Avatar answered Apr 28 '23 17:04

Yuriy Galanter