有两个方法,
var imageList = new List<string> { "icon_029.png", "icon_048.png", "icon_057.png" }; foreach (var imageName in imageList) { var imagePath = string.Format(@"<img src=""myimage/{0}""/>", imageName); this.RadioButtonList1.Items.Add(new ListItem(imagePath, imageName)); }
这样就可以显示图片了。
同理
在绑定数据源的时候用
List<FileTypeModel> list =FileManager.GetAllFileType();
for (int i = 0; i < list.Count; i++)
{
//对每一个list的Img值进行重写,即可
list[i].Img = "<img src='/" +list[i].Img+ "' alt=' '/>";
}
rblist.DataSource = list;
rblist.DataTextField = "Img";
rblist.DataValueField = "id";
rblist.DataBind();