我的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控件,不成功,该怎么实现??
}
请各位大侠搭救啊,小弟新手,急死了
<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控件,不成功,该怎么实现??
}
请各位大侠搭救啊,小弟新手,急死了
t1.Rows[0].Cells[0].Controls.Add(IMG)
用System.Web.UI.HtmlControls.HtmlTableCell试试 修改它的InnerHtml.
Img.ImageUrl = "***.jpg";
TableCell Cell = new TableCell();
Cell.Controls.Add(Img);
TableRow TRow = new TableRow();
TRow.Cells.Add(Cell);
this.T1.Rows.Add(TRow);
{
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);
}
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);
}