时间:2021-07-01 10:21:17 帮助过:19人阅读
View Code
private Dictionary<int, string> GetData()
{
Dictionary<int, string> dic = new Dictionary<int, string>();
int i = 0;
System.IO.FileInfo fi;
var Images =
from f in System.IO.Directory.GetFiles(Server.MapPath("MsSiteImages"))
orderby f descending
select f;
foreach (var filename in Images)
{
fi = new System.IO.FileInfo(filename);
dic.Add(i, "<img src='" + "MsSiteImages/" + fi.Name + "' alt='" + fi.Name +
"' title='" + fi.Name + "'/>");
i++;
}
return dic;
}
创建一个网页,并拉RadioButtonList控件进入网页:
代码如下:
<asp:RadioButtonList ID="RadioButtonList1" runat="server"></asp:RadioButtonList>
写一个方法,用来绑定数据给RadioButtonList控件,其中一个绑定类别,你可以从下面地址下载 ,解压之后,把InsusListControlUtility.dll放入站点的BIN目录中。
代码如下:
private void Data_Binding()
{
Insus.NET.InsusListControlUtility objList = new Insus.NET.InsusListControlUtility();
objList.RadioButtonListParse(this.RadioButtonList1, GetData(), "value", "key");
}
在网页的Page_Load中,引用上面的Data_Binding()方法:
代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Data_Binding();
}
运行网页的效果: