-1

I have a dropdownlist with 15datatypes,when i click the drop down it looks so clumsy ,can u suggest me how to put scroll in dropdownlist in asp.net

Karthik
  • 207
  • 15
  • 38
  • what you have tried so far? – Sachin Sep 25 '13 at 10:15
  • possible duplicate of [Hide vertical scrollbar in – CodeCaster Sep 25 '13 at 10:15
  • Why not use `size=10` instead of a dropdown? – Abhitalks Sep 25 '13 at 10:20
  • Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance. – dhein Sep 25 '13 at 10:25

3 Answers3

1

I think you want this:

<asp:DropDownList ID="ddl" width="100px" onclick="this.size=1;" onMouseOver="this.size=5;" onMouseOut="this.size=1;" style="position:absolute;" runat="server">
             <asp:ListItem>TextTextText1</asp:ListItem>
             <asp:ListItem>TextTextText2</asp:ListItem>
             <asp:ListItem>TextTextText3</asp:ListItem>
             <asp:ListItem>TextTextText4</asp:ListItem>
             <asp:ListItem>TextTextText5</asp:ListItem>
             <asp:ListItem>TextTextText6</asp:ListItem>
             <asp:ListItem>TextTextText7</asp:ListItem>   
             <asp:ListItem>TextTextText8</asp:ListItem>
             <asp:ListItem>TextTextText9</asp:ListItem>
             <asp:ListItem>TextTextText10</asp:ListItem>
             <asp:ListItem>TextTextText11</asp:ListItem>    
        </asp:DropDownList>
Bip
  • 697
  • 2
  • 10
  • 29
  • IT is working but problem with this In listview i have a dropdowncolumn it is not adjusting in listview cell – Karthik Sep 25 '13 at 11:46
0

Here TextBox will hold the selected value of the listbox. My ASPX code below:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="TextBox1" runat="server" Text="Select your item" CssClass="MyTextBox"></asp:TextBox>
            <div style="padding: 4px;" id="ItemsDiv" runat="server">
                <asp:ListBox ID="ListBox1" runat="server" onclick="callme()" CssClass="MyDropDown" Rows="6">
                </asp:ListBox>
            </div>
            <asp:DropDownExtender ID="DropDownExtender1" runat="server" TargetControlID="TextBox1"
                DropDownControlID="ItemsDiv">
            </asp:DropDownExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
<script>
   function callme() { 
           element = document.getElementById("ListBox1"); 
            str = element.options[element.selectedIndex].value; 
            document.getElementById("TextBox1").value = str; 
        } 
</script> 

else follow this link:

http://blogs.msdn.com/b/rakkimk/archive/2011/05/02/dropdownlist-html-select-vertical-scrollbar-number-of-items.aspx

or http://forums.asp.net/t/1905270.aspx?DropDownList+Scroll+Bars

0

Try to use below code.

<asp:DropDownList runat="server" ID="ddlColors" onmousedown="this.size=5;"  >
            <asp:ListItem>Red</asp:ListItem>
            <asp:ListItem>Green</asp:ListItem>
            <asp:ListItem>Blue</asp:ListItem>
            <asp:ListItem>Yellow</asp:ListItem>
            <asp:ListItem>White</asp:ListItem>
            <asp:ListItem>Black</asp:ListItem>
            <asp:ListItem>Purple</asp:ListItem>
            <asp:ListItem>no color</asp:ListItem>
    </asp:DropDownList>

Or you could use CSS's overflow property in combination with the height property on the drop down menu to add a scrollbar.

.dropmenudiv
{
  height: 300px;
  max-height: 300px;
  overflow-y: scroll;
}