我必须用它的标签动态创建图像,即超链接。为此,我编写了如下代码,但它没有显示图像,它只显示标签(超链接)。
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#。 请帮我?谢谢。
答案 0 :(得分:0)
她是代码
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)