日期:2014-05-18  浏览次数:20492 次

ImageButton的超级难题!
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="Restaurant.WebForm5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head runat="server">
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <asp:Repeater ID="First" runat="server">
  <ItemTemplate>
  <div class="pad-10">
  <table style="height: 277px; width: 1000px" >
  <tbody>
  <tr>
  <td rowspan="2" class="style15" >
  <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='~/items/<%# Eval("Pro_Image") %>' />
   
  </td>
  </tr>
  </tbody>  
  </table>
  </div>
  </ItemTemplate>
  </asp:Repeater>
  </div>
  </form>
</body>
</html>
这是前台页面代码 有问题吗???务必认真查找!
  protected void Page_Load(object sender, EventArgs e)
  {
  if (IsPostBack == false)
  {

  First.DataSource = BLL.ProManager.GetAll();
  First.DataBind();
   
  }
  }
这是后台代码!我想这应该没问题 断点调试 数据源是没有问题的!

问题来了 为什么ImageButton 的ImageUrl里的会是乱码

------解决方案--------------------
C# code

    <asp:Repeater ID="First" runat="server" OnItemDataBound="rp_list_ItemDataBound">
    protected void rp_list_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ImageButton ib = (ImageButton)e.Item.FindControl("ImageButton1");
        ib.ImageUrl = "~/items/泉水鸡.png";
    }