asp.net listbox auto height
listbox-auto-height.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string[] birds = {
"Pilotbird",
"Fernwren",
"White-browed Scrubwren",
"Weebill",
"White-throated Gerygone",
"Southern Whiteface",
"Brown Thornbill",
"Yellow-rumped Thornbill",
"Grey-crowned Babbler"
};
ListBox1.DataSource = birds;
ListBox1.DataBind();
ListBox1.Rows = ListBox1.Items.Count;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net listbox auto height</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
asp.net example - listbox auto height
</h2>
<hr width="550" align="left" color="Gainsboro" />
<br />
<asp:ListBox
ID="ListBox1"
runat="server"
AutoPostBack="true"
Font-Size="X-Large"
SelectionMode="Multiple"
Width="350"
Font-Names="Comic Sans MS"
>
</asp:ListBox>
</div>
</form>
</body>
</html>
- How to set ListBox alternate item text and background color
- How to apply alternating row color in a ListBox
- How to change ListBox item background color
- How to count ListBox selected items
- How to remove selected items from ListBox
- How to check whether an item exists in a ListBox
- How to add attributes to a ListBox items
- How to show ScrollBar in a CheckBoxList
- How to set the maximum limit of selection in a CheckBoxList
- How to set a default selected item in RadioButtonList