Q: go though a dropwdownlis items

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

Guest

Hello

I have TextBox1 and TextBox2 and Button1 and Button2. I also have
DropDownList1.
Now, when I click Button1 I want to concatenate “TextBox1 - TextBox2†and
add this item to DropDownList1.
If I have clicked Button2 I can to go though DropDownList1 and see what
items are there.

Can anyone write me C# code for this. I am quite new in ASP.Net environment.
Thanks,
 
Hi Jim,

1. Add item ddl:

DropDownList1.Items.Add(TextBox1.Text + " - " + TextBox2.Text);


2. Loop thru ddl:

foreach (ListItem item in DropDownList1.Items)
{
string txt = item.Text;
}


HTH

Elton Wang
 

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