Binding enum to RadioButtonList using C#/ ASP.Net

For example, we have an enum like this:

public enum Status

And we want to bind this with Radio Button List in C# / ASP.Net

Your .aspx will look like this:

<asp:RadioButtonList runat="server" ID="RadioButtonList1" RepeatDirection="Horizontal">

Whereas in .cs page you will bind it like this:

RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("RadioButtonList1");

rbl.DataSource = Enum.GetValues(typeof(Status));

Leave a Reply

Your email address will not be published. Required fields are marked *