Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error - 182 -The left-hand side of an assignment must be a variable, property or indexer

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

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ryno Burger
    wrote on last edited by
    #1

    Hi, I'm trying to unbox a value stored in ViewState using the code below: I can't seem to figure out what I'm doing wrong, can someone please perhaps point out what I'm doing wrong or perhaps an alternative? :wtf: (Int32)ViewState["totalLightsWatt"] = ((Int32)ViewState["totalLightsWatt"]) + (Int32.Parse(txtLightsQty.Text.Trim().ToString()) * Int32.Parse(cboLightsItems.SelectedValue.ToString())); Thanks. R

    L 1 Reply Last reply
    0
    • R Ryno Burger

      Hi, I'm trying to unbox a value stored in ViewState using the code below: I can't seem to figure out what I'm doing wrong, can someone please perhaps point out what I'm doing wrong or perhaps an alternative? :wtf: (Int32)ViewState["totalLightsWatt"] = ((Int32)ViewState["totalLightsWatt"]) + (Int32.Parse(txtLightsQty.Text.Trim().ToString()) * Int32.Parse(cboLightsItems.SelectedValue.ToString())); Thanks. R

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      hi, you can't cast the left hand side, just drop the first (Int32). If your expression (that is the right hand side) does not have the type required by the left hand side, make sure it is in parentheses (it is now) and cast it as in ViewState["totalLightsWatt"] = (viewstatetype)(....);. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


      R 1 Reply Last reply
      0
      • L Luc Pattyn

        hi, you can't cast the left hand side, just drop the first (Int32). If your expression (that is the right hand side) does not have the type required by the left hand side, make sure it is in parentheses (it is now) and cast it as in ViewState["totalLightsWatt"] = (viewstatetype)(....);. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


        R Offline
        R Offline
        Ryno Burger
        wrote on last edited by
        #3

        Hi Luc Thank you very much for your reply. Your solution made my error very clear and I get what I did wrong now. Thanks once again.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups