• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    RadioButtonList绑定图片及泛型Dictionary应用
    本博文是让你学会读取站点某一目录的图片,掌握LINQ与泛型DictionaryTKey,TValue>的使用。

    首先准备好几张图片存在站点某一目录之下,本例中的存储图片的目录名为MsSiteImages,图片你可以从微软网站下载http://windows.microsoft.com/en-US/windows/home
    我们写一个泛型数据集,将存储目录的图片信息:
    复制代码 代码如下:

    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;
    }

    创建一个网页,并拉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();
    }

    运行网页的效果:
    您可能感兴趣的文章:
    • 如何为CheckBoxList和RadioButtonList添加滚动条
    • ASP.NET中RadioButtonList绑定后台数据后触发点击事件
    • ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
    • jquery判断RadioButtonList和RadioButton中是否有选中项示例
    • js获取RadioButtonList的Value/Text及选中值等信息实现代码
    • javascript判断是否有对RadioButtonList选项选择
    • ASP.NET jQuery 实例16 通过控件CustomValidator验证RadioButtonList
    • JQuery中对服务器控件 DropdownList, RadioButtonList, CheckboxList的操作总结
    • jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist生成客户端HTML标签后的value和text值
    • ASP.NET控件之RadioButtonList详解
    上一篇:利用委托把用户控件的值显示于网页案例应用
    下一篇:ASP.NET的适配器设计模式(Adapter)应用详解
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    RadioButtonList绑定图片及泛型Dictionary应用 RadioButtonList,绑定,图片,