I am trying to bind a list collection with values to a
radiobuttonlist , but when i try to access the
selecteditem.va lue i always get the selecteditem.va lue
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page
here
if(!Page.IsPost Back)
{
ListItemCollect ion
lictest = new ListItemCollect ion();
ListItem li1 = new
ListItem("1","1 aa");
ListItem li2 = new
ListItem("2","2 aa");
lictest.Add(li1 );
lictest.Add(li2 );
RadioButtonList 1.DataSource = lictest;
RadioButtonList 1.DataBind
();
RadioButtonList 1.SelectedIndex = 0;
string strTest =
RadioButtonList 1.SelectedItem. Value.ToString( );
//strTest always returns
text instead of value
}
}
radiobuttonlist , but when i try to access the
selecteditem.va lue i always get the selecteditem.va lue
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page
here
if(!Page.IsPost Back)
{
ListItemCollect ion
lictest = new ListItemCollect ion();
ListItem li1 = new
ListItem("1","1 aa");
ListItem li2 = new
ListItem("2","2 aa");
lictest.Add(li1 );
lictest.Add(li2 );
RadioButtonList 1.DataSource = lictest;
RadioButtonList 1.DataBind
();
RadioButtonList 1.SelectedIndex = 0;
string strTest =
RadioButtonList 1.SelectedItem. Value.ToString( );
//strTest always returns
text instead of value
}
}
Comment