How to search on a dropdownlist?

Asked

Viewed 722 times

-3

I have a Dropdown that lists the names of all the banks. I need to create a method in which he brings me a set of results and among them the name of the bank. This database that my list brings (only a record) should make my Dropdownlist show this name, as if it were a search inside the drop, I do not know if I was clear.

Okay, I’ll explain. I have a combo or dropdown that lists all the banking institutions. I have a search that returns the name of the bank, by CPF or CNPJ of the researched. What I want is that when I return, for example, Bradesco Bank combo should show Bradesco Bank. I can’t do this in a combo. I’ve tried to make it go and I can’t bring anything.

João has an account in Itaú and he is registered in my system. When I type the number or CNPJ of João, will bring me the Bank Name, Agency and Account. Only that there is a combo with the name of the institutions in a panel that will be displayed. I would like the return to show in the combo the name of the bank. The txt I’ve already filled out with Account and Agency and Bank Number, but I’m having trouble showing the name of the bank because it’s in a combo. If the name of the bank does not exist in Combo, then I give a message and do what I have to do. It is WEBFORM

My difficulty is exactly at the moment of displaying the text. I did so and I cannot show the text. Where nm_bank is the bank number or combo value.

for (int i = 0; i < cmbBancos.Items.Count - 1; i++)
                    {
                        if (cmbBancos.Items[i].Value == nm_banco)
                            cmbBancos.Text = cmbBancos.Items[i].Text;
                    }
  • 6

    It was not clear, after all nor put the code where assembles the control and what already tried to do.

  • Example. I have in a combo 100 bank names. There in my search in the BD I bring Itaú BBA SA. What I want is that when I bring, my combo shows me exactly this text: Banco Itaú BBA SA.

  • When you refer to the bank, it seems that you are referring to the "Databases", it has left your question confused. Rephrase it please.

  • 4

    Not only that, it lacks full context of how the list is assembled, it makes a difference. I don’t even know if Usti is Windows Forms, ASP.Net or something else. I think someone with almost 2K of reputation should have learned by now that without relevant information, you can’t answer anything.

1 answer

0


cmbBancos.SelectedValue = nm_banco;
cmbBancos_SelectedIndexChanged(this, EventArgs.Empty);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.