注册 登录
编程论坛 ASP.NET技术论坛

请教在repeater中如何给.net控件image的imageurl赋值

kiska3088915 发布于 2010-12-03 11:38, 1075 次点击
我做的这个网页的功能是用repeater去取数据库中的商品信息,其中商品的图片路径我没存在数据库里,另外放在一个文件夹,图片名称和商品的编号一样,即图片名称:productid.jpg,在repeater里我想只要取到商品的productid,那么只要在存放商品图片的路径
"C:\inetpub\wwwroot\WebSite\shoppingcart\App_Data\goodspic\xxxxxx.jpg"中把productid代入到xxxxxx就行了,但是我不会JS,不知道怎么插,刚一直在瞎蒙,蒙不出来,我想懂JS的大虾只要一看就知道了,麻烦大虾们帮帮忙,就红色的那一句,谢谢

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1">
    <HeaderTemplate>
        <table border="1" cellpadding="0" cellspacing="0">
           <tr>
              <td colspan="7" align="center">   Product List
              </td>
           </tr>
           <tr>
              <td>
                picture
              </td>
              <td>
                 product id
              </td>
              <td>
                 product name
              </td>
              <td>
                 price
              </td>
              <td>
                 catalogue
              </td>
              <td>
                 amount
              </td>
              <td>
                 manipulation
              </td>
           </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
           <td>
               <asp:Image ID="Image1" runat="server" Height="134px" Width="170px" ImageUrl="C:\inetpub\wwwroot\WebSite\shoppingcart\App_Data\goodspic\%#Eval("productid")%.jpg" />
           </td>
           <td>
              <%#Eval("productid")%>
           </td>
           <td>
              <%#Eval("product_name")%>
           </td>
           <td>
              <%#Eval("price")%>
           </td>
           <td>
              <%#Eval("catalogue_name")%>
           </td>
           <td>
               <asp:TextBox ID="TextBoxamount" runat="server" Text="1" Width="40" MaxLength="6"></asp:TextBox>
               <br />
               <asp:RegularExpressionValidator
                   ID="RegularExpressionValidator1" runat="server" ErrorMessage="Wrong number" ControlToValidate="TextBoxamount" ValidationExpression="^[0-9]*[1-9][0-9]*$"></asp:RegularExpressionValidator>
           </td>
           <td>
               <asp:Button ID="Buttondetail" runat="server" Text="detail" CommandName="detail" CommandArgument='<%#Eval("productid")%>'/>
               <asp:Button ID="Buttonputincart" runat="server" Text="put in cart" CommandName="put in cart" CommandArgument='<%#Eval("productid") %>'/>
           </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>   
    </FooterTemplate>
    </asp:Repeater>
2 回复
#2
李亮2010-12-03 12:58
<%Eval("")%>
#3
aspic2010-12-03 15:16
如果想把数据写在页面中
应该用<img />不要老惦记着控件控件的
1