How does SelectedItem.Text.CompareTo("string") work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We tried the following:
(1)
if(RadioButtonList1.SelectedItem.Text.CompareTo("bug")==0)
row["btype"]='B';
else
row["btype"]='E';
and
(2)
if(DropDownList1.SelectedItem.Text.CompareTo("Open")==0)
cmd1.Parameters["@bstatus"].Value='O';
else if(DropDownList1.SelectedItem.Text.CompareTo("Closed")==0)
cmd1.Parameters["@bstatus"].Value='C';
else if(DropDownList1.SelectedItem.Text.CompareTo("Fixed")==0)
cmd1.Parameters["@bstatus"].Value='F';
else if(DropDownList1.SelectedItem.Text.CompareTo("Work Around")==0)
cmd1.Parameters["@bstatus"].Value='W';
else
cmd1.Parameters["@bstatus"].Value='I';

< NOW Wondering.. Why is that in the first example the ifs are reached but
not in the second > Please nyone, knowing the reason.. do share..!! Thnks..

By the way: we finally ended up using DropDownList1.SelectedIndex
 
Shaurya,

We cannot see it because we see only your code and not if there is an event
that will be triggered.

An often made mistake is that people change the index inside the index
change event. This will give only recursive actions.

I hope that this gives an idea

Cor
 
The event that triggers the action is a simple button click and definately
does not behave recursively.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top