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 |
| |||
| 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 . |
| Sponsored Links |
| |||
| 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.... |
| |||
| 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... |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |