<asp:Repeater ID="repProducts" runat="server" OnItemDataBound="repProducts_ItemDataBound">
            <ItemTemplate>
                <table id="_ctl0_tblProducts" cellspacing="0" cellpadding="0" border="0" border="0"
                    style="border-collapse: collapse;">
                    <tr>
                        <asp:DataList ID="dlistProducts" runat="server" RepeatDirection="Horizontal">
                            <ItemTemplate>
                                <td class="padding" valign="Top">
                                    <div class="divProductList">
                                        <a href="ProductDetail.aspx?id=<%#Eval("ID")%>">
<img id="ProID" src="<%#Eval("C2_Picture1")%>" alt="" width="108px" height="108px" border="0" runat="server"  />                                        </a>
                                    </div>
                                    <div class='ProductName'>
                                        <%#Eval("ProductID")%>
                                    </div>
                                </td>
                            </ItemTemplate>
                        </asp:DataList>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:Repeater>我想把
<img id="ProID" src="<%#Eval("C1_Picture1")%>" alt="" width="108px" height="108px" border="0" runat="server"  />
这个做个判断,如C1_Picture1这个字段值为NULL是就换为C2_Picture1如果这个还为空时换为C3_Picture1还换就到C4_Picture1上面代码是aspx页面的。我在代码.cs文件也找不到这个ID不知如何判断给值.

解决方案 »

  1.   

    DataList  dl = repProducts.FindControl("dlistProducts") as DataList ;
    dl.Items[0].FindControl("ProID")
    不过你那个控件要换成.NET的
      

  2.   


    <%#Eval("C1_Picture1")%> 后台代码写
    protected string GetXXXXX(object obj1,object obj2,object obj3,object obj4)
    {
    //处理
        return "";
    }<%#GetXXXXX(Eval("C1_Picture1"),Eval("C2_Picture1"),Eval("C3_Picture1"),Eval("C4_Picture1"))%> 
      

  3.   

    前台:
    <img id="ProID" src='<%# bindImage(Eval("C1_Picture1"),Eval("C1_Picture2"),Eval("C1_Picture3"),Eval("C1_Picture4"))%>' alt="" width="108px" height="108px" border="0" runat="server" />后台:    protected string bindImage(string img1,string img2,string img3,string img4)
        {
              //判断
         }
      

  4.   


        protected string bindImage(string img1, string img2, string img3, string img4)
        {
            string imgpath = null;
            if (!string.IsNullOrEmpty(img1))
            {
                imgpath = img1;
            }        if (!string.IsNullOrEmpty(img2))
            {
                imgpath = img2;
            }
            if (!string.IsNullOrEmpty(img3))
            {
                imgpath = img3;
            }
            if (!string.IsNullOrEmpty(img4))
            {
                imgpath = img4;
            }
            return imgpath;
        }后台这样写,报
    Compilation Error 
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1502: The best overloaded method match for 'CILocations.bindImage(string, string, string, string)' has some invalid arguments
      

  5.   

    让你用object  你要用string