【发布时间】:2015-11-03 04:19:15
【问题描述】:
我在 gridview 模板字段中有一个图像和一个标签。
<asp:TemplateField HeaderText = "Rate" >
<ItemTemplate>
<asp:Image ID="imgID" runat="server" />
<asp:Label id="ImageNameLabel" Text="" runat="server" />
</ItemTemplate>
</asp:TemplateField>
代码隐藏
if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = (Image)e.Row.FindControl("imgID");
img.ImageUrl = "~/Images/s1.png";
img.Height = 80;
img.Width = 80;
e.Row.Cells[6].Controls.Add(img);
Label lbl = (Label)e.Row.FindControl("ImageNameLabel")
lbl.Text = "Image Name Here";
}
当我运行应用程序时,图像和标签都显示在彼此旁边。我希望标签位于图像的正下方。
如果我添加这个
lbl.Text = "Image Name Here" + "<br/>";
然后它会反过来(标签在顶部,图像在底部)。
如何将标签移到图片正下方?
【问题讨论】:
标签: c# asp.net gridview templatefield