Bind RadioButtonList through SortedList

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 1313
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
</asp:RadioButtonList>
</form>
</body>
</html>
using System.Collections;

    protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

SortedList shl = new SortedList();
shl.Add("z", "zz");
shl.Add("f", "ff");
shl.Add("c", "cc");
shl.Add("w", "ww");
shl.Add("u", "uu");
shl.Add("i", "ii");
shl.Add("j", "jj");
RadioButtonList1.DataSource = shl;
RadioButtonList1.DataValueField = "Key";
RadioButtonList1.DataTextField="Value";
RadioButtonList1.DataBind();
}
}

Comments or Responses

Login to post response