Tutorials
Resources
Forum
Interview
Jobs
Projects
Offshore Development
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Talk to Us
|
My Profile
Sign In
Register
AdSense Revenue
Gifts
Active Members
Today
Vidhya
(85)
Shanthi M
(85)
Initiotech
(82)
Last 7 Days
UltimateRengan
(721)
Athira Appukut...
(589)
D.Jeya kumar(J...
(490)
more...
adding data from 1 listbox 2 another on selectedindexchange
Posted Date:
05 Jul 2008
Total Responses:
1
Posted By:
Gurpreet Pahwa
Member Level:
Bronze
Points
: 1
Hi,
i am able 2 add data from 1 listbox 2 another on selectedindexchange but alert message of "itm already exists" is not occuring. And d elements r being added more dan 1nce. Also, if i dnt want to use array and solve the problem by using "Contains" keyword..it is not accepting:
int j;
Boolean flag = true;
//if(!ListBox1.Items.Contains(ListBox2.SelectedItem.Text))
for (j = 0; j <= ListBox1.Items.Count - 1; j++)
{
if (ListBox2.SelectedItem.Text!= ListBox1.Items[j].Text)
{
flag = true;
}
else
{
flag = false;
}
}
if (flag == true)
{
ListBox1.Items.Add(ListBox2.SelectedItem.Text);
//ListBox2.Items.Remove(ListBox2.SelectedItem.Text);
}
else
{
Response.Write("item alrdy exists");
}
}
Responses
Author:
mohan
06 Jul 2008
Member Level:
Silver
Rating:
Points
: 4
Just Try this and let me know.........
if (ListBox2.Items.Contains(ListBox1.SelectedItem))
{
Response.Write("Items are there");
}
else
{
ListBox2.Items.Add(ListBox1.SelectedValue);
}
Post Reply
You must
Sign In
to post a response.
Next :
Transfering data from textbox to listbox.
Previous :
Transferring data from 1 list box 2 another on button click!
Return to Discussion Forum
Post New Message
Category:
ASP.NET
Related Messages
mail
Gridview row moves up/down
Grid View VERY URGENT!!!!!
what is in-line code & code behind code?
To Rekha......
dotNet Slackers
BizTalk Adaptors
Web Design
web conferencing
Contact Us
Privacy Policy
Terms Of Use