ListItemCollection and getting value back from radiobuttonlist

C

casey

I am trying to bind a list collection with values to a
radiobuttonlist, but when i try to access the
selecteditem.value i always get the selecteditem.value


private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page
here
if(!Page.IsPostBack)
{
ListItemCollection
lictest = new ListItemCollection();
ListItem li1 = new
ListItem("1","1aa");
ListItem li2 = new
ListItem("2","2aa");

lictest.Add(li1);
lictest.Add(li2);

RadioButtonList1.DataSource = lictest;
RadioButtonList1.DataBind
();

RadioButtonList1.SelectedIndex = 0;
string strTest =
RadioButtonList1.SelectedItem.Value.ToString();
//strTest always returns
text instead of value
}

}
 
G

Guest

Figured out a way around, by setting listitems directly
to RadioButtonList1.Items.Add(

but still don't understand why you lose the Value part of
a listItem when you bind a listitemCollection to a RBL

hmmm

casey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top