Search code examples
asp.netradio-buttonradiobuttonlist

Radiobutton list select an Item on page Load


I have a radiobuttonlist that i am populating on runtime with a datasource. Now what I want is to select the item that has text "Daily At" by default when page is loaded. How to achieve this?


Solution

  • foreach (ListItem item in RadioButtonList1.Items)
                {
                    if (item.Text.Contains("Daily At"))
                    {
                        item.Selected = true;
                        break;
                    }
                }