开发者

How to create images dynamically with labels in asp.net c#

开发者 https://www.devze.com 2023-03-25 16:19 出处:网络
I have to create images dynamically with its label i.e hyperlinks. For that i have written code as follows but its not displaying images, it displays labels (hyperlinks) only.

I have to create images dynamically with its label i.e hyperlinks. For that i have written code as follows but its not displaying images, it displays labels (hyperlinks) only.

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 Im开发者_StackOverflowage();
            img.ImageUrl =  Convert.ToString(dsfile.Tables[0].Rows[i]["FilePath"]);           
            PHFilename.Controls.Add(img);
    }

Asp.net C#. Please help me? Thank you.


hers is code

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消