the left hand side of an assignment must be a variable

Last post 04-16-2009 10:55 PM by drpcken. 3 replies.

Sort Posts:

  • the left hand side of an assignment must be a variable

    04-16-2009, 9:48 PM
    • Member
      454 point Member
    • drpcken
    • Member since 12-15-2005, 12:45 PM
    • Jackson, TN
    • Posts 342

     I have a custom user control I created and I'm trying to open up the controls inside of it to the parent aspx page that it will reside in.  I have a radio button so I created a public property like so:

     

     

    public Int32 _radioEnroll
        {
            get { return Convert.ToInt32(radioEnroll.SelectedValue); }
            set { Convert.ToInt32(radioEnroll.SelectedValue) = value; }
        }

      

    Now when I try this, the get works fine, however the set errors out saying:

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

     I've tried everything including casting but it won't work.  The Value of the radios are all integers and will be stored in my db as integers.


    What am I missing?

  • Re: the left hand side of an assignment must be a variable

    04-16-2009, 10:23 PM
    Answer
    • All-Star
      88,529 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,236
    • Moderator
      TrustedFriends-MVPs

    This works:

     

        public Int32 _radioEnroll
        {
            get { return Convert.ToInt32(radioEnroll.SelectedValue); }
            set { radioEnroll.SelectedValue = value.ToString(); }
        }
    
     
    Steve Wellens

    My blog
  • Re: the left hand side of an assignment must be a variable

    04-16-2009, 10:53 PM
    • Member
      454 point Member
    • drpcken
    • Member since 12-15-2005, 12:45 PM
    • Jackson, TN
    • Posts 342

     Awesome that does work!

     Can you explain why though?  The property is setup as an Int32... I don't understand why the SET is a value that has to be converted into a string...

  • Re: the left hand side of an assignment must be a variable

    04-16-2009, 10:55 PM
    • Member
      454 point Member
    • drpcken
    • Member since 12-15-2005, 12:45 PM
    • Jackson, TN
    • Posts 342

     Ahh I just answered my own question I think... The SelectedValue is always a string... :)  I think I understand now.


    Thank you very much!!

Page 1 of 1 (4 items)