Bind RadioButtonList through HashTable

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 2180
<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)
{

Hashtable hsh = new Hashtable();
hsh.Add("1", "Ab");
hsh.Add("2", "Ac");
hsh.Add("3", "Ad");
hsh.Add("4", "Ae");
hsh.Add("5", "Af");
RadioButtonList1.DataSource = hsh;
RadioButtonList1.DataValueField = "Key";
RadioButtonList1.DataTextField="Value";
RadioButtonList1.DataBind();
}
}

Comments or Responses

Login to post response