Saturday, July 20, 2013

RadioButtonList with ListItem collection datatext and datavalue field issue

Hi ,
Radiobutton list is working fine with List but if we want to bind with listitem collection then , it bind the text value with value field as well.
so, following is the sample code which solves this issue.

 
 RadioButtonList.DataSource = itemCollection; // this is list Item collection
 RadioButtonList.DataTextField = "Text";
 RadioButtonList.DataValueField = "Value";
 RadioButtonList.DataBind();


:) 

No comments: