views:

190

answers:

4

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???

A: 

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).

Alex
+1  A: 

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.

TLiebe
the problem im facing with using the ajax kit is that im using a masterpage and dont know how to use ajax control with it.. can you help me with that. it will be quiet helpful.. thanks
There's no reason you can't use AJAX with master pages. Have a look at http://www.asp.net/(S(sf10gzjodvrpce55el2p5cnk))/learn/master-pages/tutorial-08-cs.aspx for a tutorial. Good luck.
TLiebe
+1  A: 

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.

Mitchel Sellers
+1  A: 

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>
Madi D.
i did that but i dont get the scroll on the side... how do i get that..thanks
Enclose it with a div tag , that has a smaller height than it, and overflow = auto,, i edited my answer to have a sample code :)
Madi D.
this will not work because there is no scroll inside the list box but it has a scroll outside... i tried this.... also you have closed the div twice...but that i modified, so was not an issue..
fixed the doubled ending tag, and i dont get you.. if you add more than 1 item, the scroll bar shows automatically !
Madi D.
i just tested it, by adding the data from the code behind, and the listbox shows the scroll bar, and without the need for the div tags too!
Madi D.
Ok.. now this is a problem... are u using IE coz it works with that but try using firefox.. and you will understand what i mean...
is there a way out of this....???
oh okie,saw what you meant, i am using Chrome BTW...
Madi D.
ya i saw that with chrome... but now is there a way out or ajax is my last resort...