如何在asp.net c#中动态创建带有标签的图像
本文关键字:创建 标签 图像 动态 asp net | 更新日期: 2023-09-27 18:04:34
我必须动态创建图像与它的标签,即超链接。为此,我编写了如下代码,但它不显示图像,它只显示标签(超链接)。
string fname="";
string fpath = "";
DataSet dsfile = new DataSet();
//For fetching data that is inserted earlier in database
SqlDataAdapter dafile = new SqlDataAdapter("select FileName,FilePath from CRM_CustomerAttachment where CustomerID='" + cust + "'", FlyCon);
dafile.Fill(dsfile);
if (dsfile != null)
{
fname = Convert.ToString(dsfile.Tables[0].Rows[0]["FileName"]);
fpath = Convert.ToString(dsfile.Tables[0].Rows[0]["FilePath"]);
}
PlaceHolder PHFilename = (PlaceHolder)FVViewCustData.FindControl("PHFilename");//FVViewCustData is formview & placeholder is inside the formview
for (int i = 0; i < dsfile.Tables[0].Rows.Count; i++)
{
HyperLink hypname = new HyperLink();
hypname.Text = Convert.ToString(dsfile.Tables[0].Rows[i]["FileName"]) + "</br>";
PHFilename.Controls.Add(hypname);
Image img = new Image();
img.ImageUrl = Convert.ToString(dsfile.Tables[0].Rows[i]["FilePath"]);
PHFilename.Controls.Add(img);
}
Asp.net c#。请帮帮我?谢谢你。
她的代码
Dim img As New Image
img.ID = "img1"
img.ImageUrl = "http://www.prodeveloper.org/wp-content/uploads/2008/10/stackoverflow-logo-250.png"
PlaceHolder1.Controls.Add(img)