RETRIVING RADIOBUTTON LIST FROM SESSION

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 805  View(s)
Ratings:
Rate this:

Retriving radiobutton list selection from session. I have a radiobutton list. I want to have what I selected when I return to the page. The radiobutton list is filled from a array of strings

 

Adding selection to the session

 

                  Session["selection"] = RadioButtonList1.SelectedIndex;

page load

 

                    if (!IsPostBack)

                    {

                    RadioButtonList1.SelectedIndex = (string)Session["selection"];

                    }

Not working not sure why

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: Retriving radiobutton list from session

    ListControl.SelectedIndex Property

    Gets or sets the lowest ordinal index of the selected items in the list.

    Try This:

    RadioButtonList1.SelectedIndex = Convert.ToInt32(Session["selection"]);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!