主頁 > 知識(shí)庫 > RadioButtonList綁定圖片及泛型Dictionary應(yīng)用

RadioButtonList綁定圖片及泛型Dictionary應(yīng)用

熱門標(biāo)簽:團(tuán)購網(wǎng)站 銀行業(yè)務(wù) Linux服務(wù)器 服務(wù)器配置 科大訊飛語音識(shí)別系統(tǒng) Mysql連接數(shù)設(shè)置 阿里云 電子圍欄
本博文是讓你學(xué)會(huì)讀取站點(diǎn)某一目錄的圖片,掌握LINQ與泛型DictionaryTKey,TValue>的使用。

首先準(zhǔn)備好幾張圖片存在站點(diǎn)某一目錄之下,本例中的存儲(chǔ)圖片的目錄名為MsSiteImages,圖片你可以從微軟網(wǎng)站下載http://windows.microsoft.com/en-US/windows/home
我們寫一個(gè)泛型數(shù)據(jù)集,將存儲(chǔ)目錄的圖片信息:
復(fù)制代碼 代碼如下:

View Code
private Dictionaryint, string> GetData()
{
Dictionaryint, string> dic = new Dictionaryint, 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;
}

創(chuàng)建一個(gè)網(wǎng)頁,并拉RadioButtonList控件進(jìn)入網(wǎng)頁:
復(fù)制代碼 代碼如下:

asp:RadioButtonList ID="RadioButtonList1" runat="server">/asp:RadioButtonList>

寫一個(gè)方法,用來綁定數(shù)據(jù)給RadioButtonList控件,其中一個(gè)綁定類別,你可以從下面地址下載 ,解壓之后,把InsusListControlUtility.dll放入站點(diǎn)的BIN目錄中。
復(fù)制代碼 代碼如下:

private void Data_Binding()
{
Insus.NET.InsusListControlUtility objList = new Insus.NET.InsusListControlUtility();
objList.RadioButtonListParse(this.RadioButtonList1, GetData(), "value", "key");
}

在網(wǎng)頁的Page_Load中,引用上面的Data_Binding()方法:
復(fù)制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Data_Binding();
}

運(yùn)行網(wǎng)頁的效果:
您可能感興趣的文章:
  • 如何為CheckBoxList和RadioButtonList添加滾動(dòng)條
  • ASP.NET中RadioButtonList綁定后臺(tái)數(shù)據(jù)后觸發(fā)點(diǎn)擊事件
  • ASP.NET服務(wù)器端控件RadioButtonList,DropDownList,CheckBoxList的取值、賦值用法
  • jquery判斷RadioButtonList和RadioButton中是否有選中項(xiàng)示例
  • js獲取RadioButtonList的Value/Text及選中值等信息實(shí)現(xiàn)代碼
  • javascript判斷是否有對(duì)RadioButtonList選項(xiàng)選擇
  • ASP.NET jQuery 實(shí)例16 通過控件CustomValidator驗(yàn)證RadioButtonList
  • JQuery中對(duì)服務(wù)器控件 DropdownList, RadioButtonList, CheckboxList的操作總結(jié)
  • jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標(biāo)簽后的value和text值
  • ASP.NET控件之RadioButtonList詳解

標(biāo)簽:江蘇 大理 衢州 廣元 棗莊 萍鄉(xiāng) 衡水 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《RadioButtonList綁定圖片及泛型Dictionary應(yīng)用》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266