Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you tried to set the TopIndex property?</p> <pre><code>listBox.TopIndex = itemIndex; </code></pre> <hr> <p>Sorry, my first understanding of your question was completely wrong. I think you can do it by using javascript. I tested the sample below on Windows 7 and IE8 and it worked.</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"&gt; function setSelectedIndex() { var listBox = $get('listBox'); var textBox = $get('textBox'); listBox.selectedIndex = textBox.value; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:ListBox runat="server" ID="listBox"&gt; &lt;asp:ListItem Text="A" Value="A" /&gt; &lt;asp:ListItem Text="B" Value="B" /&gt; &lt;asp:ListItem Text="C" Value="C" /&gt; &lt;asp:ListItem Text="D" Value="D" /&gt; &lt;asp:ListItem Text="E" Value="E" /&gt; &lt;asp:ListItem Text="F" Value="F" /&gt; &lt;asp:ListItem Text="G" Value="G" /&gt; &lt;asp:ListItem Text="H" Value="H" /&gt; &lt;asp:ListItem Text="I" Value="I" /&gt; &lt;asp:ListItem Text="K" Value="K" /&gt; &lt;/asp:ListBox&gt; &lt;asp:TextBox runat="server" ID="textBox" Text="8" /&gt; &lt;asp:Button runat="server" ID="button" Text="Select" OnClientClick="setSelectedIndex(); return false;" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload