Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparison with DropDownList SelectedValue
Message
From
27/01/2011 12:43:53
 
 
To
27/01/2011 12:38:07
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01497545
Message ID:
01497555
Views:
30
>Sorry, I was probably a bit confusing in my message. I tried this first:
>
>
if (this.cboStatus.SelectedValue == 11 || this.cboStatus.SelectedValue == 7)
>
>which didn't work because SelectedValue is apparently a string. I thought it would have been an int as it was bound to an int value.
>
>So I then tried this:
>
>
if (this.cboStatus.SelectedValue == '11' || this.cboStatus.SelectedValue == '7')
>
>Which didn't work either.
>
>I eventually got it right with this:
>
>
if (this.cboStatus.SelectedValue == "11" || this.cboStatus.SelectedValue == "7")
>
>So, it seems that single and double quotation marks are not interchangeable in C# as they are in VFP. Is that correct?

Single quotes are for Character literals. e.g.
Char x = 'c';
String x2 = "c";
>
>
>
>>Looks like you need to cast the two strings as ints : (int)"11", no?
>>
>>
>>>Hi,
>>>
>>>I want to compare the SelectedValue of a Drop Down List with a status value, but I'm getting this error:
>>>
>>>Operator '==' cannot be applied to operands of type 'string' and 'int
>>>
>>>My code is:
>>>
>>>UPDATE: changed the next line to include "" marks and got it fixed, I had been using single quotations and that wasn't working
>>>
            if (this.cboStatus.SelectedValue == "11" || this.cboStatus.SelectedValue == "7")
>>>            {
>>>                this.lblDeathDate.Visible = true;
>>>                this.txtDeathDate.Visible = true;
>>>                this.btnDisplayDeathDateCalendar.Visible = true;
>>>            }
>>>
>>>My DropDownList definition is:
>>>
>>>
                            <mm:mmDropDownList ID="cboStatus" runat="server" BindingSource="Status" BindingSourceDisplayMember="Status"
>>>                                BindingSourceValueMember="StatusPK" BindingValueSource="Policy" BindingValueSourceMember="StatusFK"
>>>                                Enabled="False" AutoPostBack="true" OnTextChanged="cboStatus_TextChanged">
>>>                            </mm:mmDropDownList>
>>>
>>>
>>>What do I need to do to compare this?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform