开发者

listbox value with one row

I have a to select a number between one to thousand...

I dont want to use a dropdown list because there are too many values instead i want the box which has the values to act like a listbox with up and down arrows within the box...

I tried using the listbox with one row and it starts acting like a dropdownlist...

<asp:ListBox ID="ListBox1" runat="server" AppendDataBoundItems="True" Rows="1">

            </asp:ListBox>

I am filling this listbox with from the codebehind开发者_开发百科..

any suggestions???


Why not use something like a numeric up-down control? It requires AJAX but that might not be a problem. There is a sample here.


Your best bet here is to use the Numeric Up/Down control that is part of the ASP.NET AJAX Control Toolkit.

Here is the information/demo page for it.


Unless resizing the Listbox is not an Option you can try and resize it to show only 1 row, that would do the trick..

oh but remember to remove the rows="1" if you do that

Edit: Added sample code, and added Div to show the horizontal Scroll bar

  <Div style="Height:100px;Width:200px;Overflow:Auto">

<asp:ListBox ID="ListBox1" runat="server" EnableTheming="True" 
    onselectedindexchanged="ListBox1_SelectedIndexChanged" Height="23px" Width="54px">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
    <asp:ListItem>3</asp:ListItem>
    <asp:ListItem>4</asp:ListItem>
    <asp:ListItem>5</asp:ListItem>
    <asp:ListItem>6</asp:ListItem>
    <asp:ListItem>7</asp:ListItem>
    <asp:ListItem>8</asp:ListItem>
    <asp:ListItem>9</asp:ListItem>
    <asp:ListItem></asp:ListItem>
</asp:ListBox>
 </Div>


It's called a SpinBox in WinForms. In ASP.NET, there are control vendors who have implemented this (like DevExpress) but you can also quite easily do it yourself, a bit like this (needs some formatting but that's up to you).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜