Error - 182 -The left-hand side of an assignment must be a variable, property or indexer
-
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 -
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. Rhi, 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 inViewState["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.
-
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 inViewState["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.
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.