【问题标题】:ASP.Net add image to radiobuttonlist items on loadASP.Net 在加载时将图像添加到单选按钮列表项
【发布时间】:2011-08-23 21:14:22
【问题描述】:

我有一个绑定到数据表的 RadioButtonList。在数据表中,有一列是图片的 url,另一列是描述。

以下是我现在正在做的事情(虽然没有工作):

     foreach ( acryliccolor scurrent in ssmacryliccolor )
     {
        DataRow dr = dt.NewRow();
        dr["TEXT"] = "<img src=\"\\colorswatches\\" + scurrent.SwatchURL + "\" alt=\"\" border=\"0\" /><span style=\"margin-right:21px;\"></span>"  + scurrent.Color;
        dr["VALUE"] = "ID|SC_" + scurrent.ID.ToString() + ";CSID|" + current.ID.ToString() + ";JS|radiosimple(this)";
        dt.Rows.Add(dr);
     }
     this.rblAcrylicColors.DataSource = dt;
     this.rblAcrylicColors.DataTextField = "TEXT";
     this.rblAcrylicColors.DataValueField = "VALUE";
     this.rblAcrylicColors.DataBind();

如何在每个单选按钮项的说明旁边添加图片?

【问题讨论】:

    标签: asp.net image data-binding radiobuttonlist


    【解决方案1】:

    您是否尝试过将项目动态添加到 radiobuttonlist.Items 集合?

    this.rblAcrylicColors.Items.Add(String.Format("<img src={0} />", "url"));
    

    您是否还检查了当前尝试的 html 输出?有没有img标签?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      • 2013-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多