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 (permalink)  
Old 02-18-2008, 10: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
Sponsored Links
  #2 (permalink)  
Old 03-12-2008, 04:28 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
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 (permalink)  
Old 03-12-2008, 09: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 (permalink)  
Old 03-13-2008, 04:02 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
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 (permalink)  
Old 04-08-2008, 04:13 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
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 (permalink)  
Old 04-08-2008, 10: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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How i will get the selected value from Listbox( if selection mode=multiple) Mramesh C# Programming 3 02-07-2008 04:20 AM
ASP.net threading issue when populating a listbox $enthil ASP and ASP.NET Programming 6 11-04-2007 11:24 PM
Listbox onselected event problem $enthil ASP and ASP.NET Programming 2 11-01-2007 10:36 PM
Can we put the reference dll in to a specific folder? amansundar C# Programming 3 10-29-2007 12:51 AM
goto specific scene nssukumar Flash Actionscript Programming 1 07-24-2007 01:14 AM


All times are GMT -7. The time now is 06:56 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0