IT Community - Software Programming, Web Development and Technical Support

Extracting specific elements from listbox

This is a discussion on Extracting specific elements from listbox within the ASP and ASP.NET Programming forums, part of the Web Development category; Hello, Consider a listbox having elements such as 1. Apple 2. Banana 3. PineApple 4. Grapes In a textbox a ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 02-18-2008, 09:37 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Question Extracting specific elements from listbox

Hello,

Consider a listbox having elements such as

1. Apple
2. Banana
3. PineApple
4. Grapes


In a textbox a value is given such as 1,2 or 3. Using this input the 1 or 2 or 3 elements text must want to be displayed such as 'Apple' , 'Banana' etc

Help me .
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 03-12-2008, 03:28 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 188
poornima is on a distinguished road
Smile Re: Extracting specific elements from listbox

Hi,
Tell me Clearly...
Do u have button along with text box?..So that if u enter 1 in textbox and Click that button ,Apple is selected in the ListBox control....I need this detail to proceed with this further....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 03-12-2008, 08:12 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Default Re: Extracting specific elements from listbox

Yes, There will be a button. The action is to be took palce after clicking the button.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 03-13-2008, 03:02 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 188
poornima is on a distinguished road
Smile Re: Extracting specific elements from listbox

Hi,
Try like this,
It is very similar to DropDownList...
In aspx page,
<div>
<asp :TextBox ID="sampleTextBox" runat="server"></asp:TextBox>
<asp :Button ID="selectButton" runat="server" Text="Select" OnClick="selectButton_Click" />
</div>
<div>
<asp :ListBox ID="sampleListBox" runat="server">
<asp :ListItem Text="Apple" Value="Apple"></asp:ListItem>
<asp :ListItem Text="Banana" Value="Bannana"></asp:ListItem>
<asp :ListItem Text="PineApple" Value="PineApple"></asp:ListItem>
<asp :ListItem Text="Grapes" Value="Grapes"></asp:ListItem>
</asp :ListBox>
</div>
Write this Coding in Button Click Event... in code-behind
protected void selectButton_Click(object sender, EventArgs e)
{
if (sampleTextBox.Text == "1")
sampleListBox.SelectedIndex = 0;
if (sampleTextBox.Text == "2")
sampleListBox.SelectedIndex = 1;
if (sampleTextBox.Text == "3")
sampleListBox.SelectedIndex = 2;
if (sampleTextBox.Text == "4")
sampleListBox.SelectedIndex = 3;
}
So according to the value in textbox the value is selected in ListBox.
This is just a sample coding,try to implement this in your project...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 04-08-2008, 03:13 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 188
poornima is on a distinguished road
Smile Re: Extracting specific elements from listbox

hi Kirubananth,
Work out this and let me know ,Is this satisfy ur need?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 04-08-2008, 09:35 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Smile Re: Extracting specific elements from listbox

Hi poornima,
Thank you for your help. It is really useful to me da.
__________________
--Kirubhaa. Born to win--
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting IPTC data from Image ultimate_senthil C# Programming 0 05-29-2009 12:22 PM
listbox packirisamy ASP and ASP.NET Programming 0 11-10-2008 01:49 AM
How i will get the selected value from Listbox( if selection mode=multiple) Mramesh C# Programming 3 02-07-2008 03:20 AM
ASP.net threading issue when populating a listbox $enthil ASP and ASP.NET Programming 6 11-04-2007 10:24 PM
Listbox onselected event problem $enthil ASP and ASP.NET Programming 2 11-01-2007 09:36 PM


All times are GMT -7. The time now is 04:13 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0