如何在table中添加image?

lunyx 2008-08-19 04:17:47
我的table如下:
<asp:Table ID="t1" runat="server" BorderColor="Red" BorderWidth="1px" Width="155px">
<asp:TableRow runat="server" BackColor="#FFC0FF">
<asp:TableCell runat="server">rrr</asp:TableCell>
</asp:TableRow>
</asp:Table>
现在我用一个按钮来完成:
protected void Button1_Click(object sender, EventArgs e)
{
t1.Rows[0].Cells[0].Text = "<asp:Image ID=Image1 runat=server Height=17px ImageUrl=top.gif Width=15px />"; //想在格子中放入image控件,不成功,该怎么实现??
}
请各位大侠搭救啊,小弟新手,急死了
...全文
146 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lunyx 2008-08-19
  • 打赏
  • 举报
回复
谢谢各位大侠,问题解决了
kenning 2008-08-19
  • 打赏
  • 举报
回复
再加个Lable
protected void Button1_Click(object sender, EventArgs e)
{
Image Img = new Image();
Img.ImageUrl = "***.jpg";
Lable LB=new Lable();
LB.Text="sdfsdf";
TableCell Cell = new TableCell();
Cell.Controls.Add(Img);
Cell.controls.AddAt(1,LB) ;
TableRow TRow = new TableRow();
TRow.Cells.Add(Cell);
this.Table1.Rows.Add(TRow);
}
lunyx 2008-08-19
  • 打赏
  • 举报
回复
kenning 兄也可以添加图像啊,就是把原来的 text内容给覆盖了,能不能不要覆盖啊
lunyx 2008-08-19
  • 打赏
  • 举报
回复
用 whycom 兄的方法是可以加,可是他原来的的t1.Rows[0].Cells[0].Text= "rrr"就不见了,只能显示图像了,能不能不要覆盖原来的text呀
kenning 2008-08-19
  • 打赏
  • 举报
回复
protected void Button1_Click(object sender, EventArgs e)
{
Image Img = new Image();
Img.ImageUrl = "***.jpg";
TableCell Cell = new TableCell();
Cell.Controls.Add(Img);
TableRow TRow = new TableRow();
TRow.Cells.Add(Cell);
this.Table1.Rows.Add(TRow);
}
kenning 2008-08-19
  • 打赏
  • 举报
回复
Image Img = new Image();
Img.ImageUrl = "***.jpg";
TableCell Cell = new TableCell();
Cell.Controls.Add(Img);
TableRow TRow = new TableRow();
TRow.Cells.Add(Cell);
this.T1.Rows.Add(TRow);
lunyx 2008-08-19
  • 打赏
  • 举报
回复
我顶
优途科技 2008-08-19
  • 打赏
  • 举报
回复
好像dataTable中没有办法放入图片。可能需要第三方控件实现了
Zine_Alone 2008-08-19
  • 打赏
  • 举报
回复

用System.Web.UI.HtmlControls.HtmlTableCell试试

修改它的InnerHtml.

whycom 2008-08-19
  • 打赏
  • 举报
回复
System.Web.UI.WebControls.Image IMG = new ....
t1.Rows[0].Cells[0].Controls.Add(IMG)

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧