RadioButtonList Horizontal Layout
RadioButtonList is an asp.net list web server control that render a single selection
radio button group in a web browser. by default radiobuttonlist server control's items
display vertically.
The following asp.net c# example code demonstrate us how can we display radiobuttonlist server control's items in horizontal layout. radiobuttonlist control have a built in property named RepeatDirection that get or set the direction in which the radio buttons within the group are displayed.
RepeatDirection property have two possible values those are Vertical and Horizontal. if we set the radiobuttonlist RepeatDirection property value to Horizontal then radiobuttonlist items are display horizontally. we must ignore RepeatLayout and RepeatColumns properties so that radiobuttonlist items can display horizontally in a single table row.
The following asp.net c# example code demonstrate us how can we display radiobuttonlist server control's items in horizontal layout. radiobuttonlist control have a built in property named RepeatDirection that get or set the direction in which the radio buttons within the group are displayed.
RepeatDirection property have two possible values those are Vertical and Horizontal. if we set the radiobuttonlist RepeatDirection property value to Horizontal then radiobuttonlist items are display horizontally. we must ignore RepeatLayout and RepeatColumns properties so that radiobuttonlist items can display horizontally in a single table row.
radiobuttonlist-horizontal-layout.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
RadioButtonList1.Items.Add(new ListItem("Northern Raven", "1"));
RadioButtonList1.Items.Add(new ListItem("Piapiac", "2"));
RadioButtonList1.Items.Add(new ListItem("Rook", "3"));
RadioButtonList1.Items.Add(new ListItem("Carrion Crow", "4"));
RadioButtonList1.Items.Add(new ListItem("Blue Jay", "5"));
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net radiobuttonlist horizontal layout</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
asp.net example - radiobuttonlist horizontal layout
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Text="select an item from radiobuttonlist...."
Font-Size="Large"
Width="350"
>
</asp:Label>
<br /><br />
<asp:RadioButtonList
ID="RadioButtonList1"
runat="server"
RepeatDirection="Horizontal"
AutoPostBack="true"
>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>

- How to sort ListBox items
- How to sort ListBox items alphabetically
- How to get CheckBoxList checked items
- How to set default checked items in CheckBoxList
- How to get selected value from RadioButtonList
- How to check that RadioButtonList has a selected item
- How to set a default selected item in RadioButtonList
- How to add margin between items in a RadioButtonList
- How to set RadioButtonList items vertical alignment
- How to add vertical space between items in a RadioButtonList