| |

VerySource

 Forgot password?
 Register
Search
View: 1467|Reply: 18

ListBox problem

[Copy link]

5

Threads

19

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-5 12:30:01
| Show all posts |Read mode
How to get the value in ListBox? ?
How to clear the data in listBox? ?
anxious
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-5 16:03:01
| Show all posts
Response.Write (Request.Form ["ListBox1"]);
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-5 16:06:02
| Show all posts
this.ListBox1.Items.Clear ();
Reply

Use magic Report

5

Threads

19

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-5 17:00:01
| Show all posts
this.ListBox2.Items.Add (Request.Form [ListBox1] .ToString ());
What's wrong? ? How to change? ?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-5 17:24:01
| Show all posts
Should be Request.Form ["ListBox1"]


Why use it like this? Guide this value (may be multiple 1, 2, 3) to listbox2?
Reply

Use magic Report

5

Threads

19

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 South Africa

 Author| Post time: 2020-1-5 17:39:01
| Show all posts
Because the value in listbox1 needs to be taken out and displayed in listbox2
?
this.ListBox2.Items.Add (Request.Form [ListBox1]);
No way
Reply

Use magic Report

5

Threads

19

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Brazil

 Author| Post time: 2020-1-5 17:45:01
| Show all posts
Sorry, there is no "", OK.
Thank you
Reply

Use magic Report

5

Threads

19

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-5 17:51:01
| Show all posts
Oh, can you enter data in listbox
? ? If so, how to write it? ?
thank
Reply

Use magic Report

0

Threads

64

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-1-5 18:39:02
| Show all posts
Roughly:

foreach (ListItem item in ListBox1.Items)
  if (item.Selected)
  {
     string s = item.Value; //.Text?
     if (! ListBox2.Items.FindByValue (s))
        ListBox2.Items.Add (new ListItem (item.Text, item.Value));
  }
Reply

Use magic Report

0

Threads

64

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-1-5 19:00:01
| Show all posts
Change it:

if (! ListBox2.Items.FindByValue (s))-> if (ListBox2.Items.FindByValue (s) == null)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list