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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| 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 . |
|
#2
| |||
| |||
| 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.... |
|
#3
| |||
| |||
| Yes, There will be a button. The action is to be took palce after clicking the button. |
|
#4
| |||
| |||
| 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... |
|
#5
| |||
| |||
| hi Kirubananth, Work out this and let me know ,Is this satisfy ur need? |
|
#6
| |||
| |||
| Hi poornima, Thank you for your help. It is really useful to me da.
__________________ --Kirubhaa. Born to win-- |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |
Our Partners |