AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 List box
Posted by Ankur Dagar on  10/28/2009 1:30:15 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
How to transfer our data from one listbox to another in asp.net 3.5 using C#?

Post Your Reply Post New Question

 Viewer's Reply
Asp.Net ListBox Adding Item
Answered By Moderator1 on 10/30/2009 10:06:01 PM
1. Add 2 Listbox control in your aspx page.
2. Make the AutoPostBack Property of ListBox1 as True.
3. You can add Items to ListBox1 with the below codes.
ListItem item1= new ListItem();
item1.Text = "Joseph";
item1.Value = "1";
ListBox1.Items.Add(item1);
ListItem item2= new ListItem();
item2.Text = "AnkurDagar";
item2.Value = "1";
ListBox1.Items.Add(item2);
4. In the SelectedIndexChange event of the ListBox1, write the below code
ListItem additem= new ListItem();
additem.Text = ListBox1.SelectedItem.Text;
additem.Value =ListBox1.SelectedValue;
ListBox2.Items.Add(additem);

Try this.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Backup and Recovery Best Practices for Microsoft SQL Server 2005
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!
Simply JavaScript - Free 150 Page Preview!