当前位置:编程学习 > C#/ASP.NET >>

如何把图片对象插入到Cell中???

我数据库中存储的是图片的路径  想在后台遍历显示图片 
肯定要在后台用代码分别创建行、单元格的对象 然后添加吧?
最后创建Image的对象 可是怎么能把Image的对象添加到单元格中呢?? --------------------编程问答--------------------

 <asp:DataList ID="ImgNews" runat="server" Width="99%" RepeatColumns="4">
                                        <ItemStyle VerticalAlign="Top" HorizontalAlign="center"></ItemStyle>
                                        <ItemTemplate>
                                            <table border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td valign="top">
                                                        <table border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <td valign="middle" align="center" class="3photobg">
                                                                    <table border="0" cellspacing="0" cellpadding="0">
                                                                        <tr>
                                                                            <td align="center" valign="middle">
                                                                                <img src='../DownloadFiles/article/<%# Eval("FalseFileName").ToString() %>'
                                                                                    width="160" height="120" border="0" />
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td height="35" valign="top" align="center" class="maintext">
                                                                    <%#mystore.CutString(Eval("Title").ToString(), 80)%>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                    <td width="12">
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                    </asp:DataList>
--------------------编程问答--------------------
读出数据源  绑定dataList 或者 gridview  就ok了 --------------------编程问答-------------------- 楼上的这个代码得写在前台页面上吧。。。 我的图片是动态读取出来的  所以得写在后台。。。 
 //打印logo
        for (int i = 0; i < ds.Tables[0].Rows.Count; i += 3)
        {
            TableRow row = new TableRow();
            row.ID = i.ToString();
            this.friendTable.Rows.Add(row);
            TableCell cell1 = new TableCell();
            cell1.ID = "cell" + ds.Tables[0].Rows[i]["id"].ToString();
            Image image1 = new Image();
            image1.ID = "image" + ds.Tables[0].Rows[i]["id"].ToString();
            image1.ImageUrl = ds.Tables[0].Rows[i]["logoAdd"].ToString();
            //如何把图片对象加载到单元格中

这是我写的前面部分。。 后面怎么把image加进去。。。 --------------------编程问答-------------------- cell有没有方法是可以add图片对象的呢? --------------------编程问答-------------------- cell.Controls.Add(image1);
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,