Click here to Skip to main content
15,910,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All
i have an unordered list
ASP.NET
<ul id="ulx"  runat="server">


in which i have to dynamically Add Li with image and link for that i have done
following code
C#
for (int i = 0; i < dt.Rows.Count; i++)
            {
                string url = string.Empty;
                url = dt.Rows[i]["ProductImage"].ToString();
                string inputString = String.Format(@"""{0}""", url);               
                HtmlGenericControl li = new HtmlGenericControl();
                li.TagName = "li";
                li.InnerHtml = "<a href=" + " product_id="].ToString() + ">" + "<img src=" + inputString + " width='" + "100" + "' height='" + "75" + "' runat='"+"Server"+"'s/>" + "</a>";
                ulx.Controls.Add(li);
            }
in this code link is working but image is not displayed plz help me.
Posted
Updated 9-Jul-12 22:52pm
v3
Comments
pradiprenushe 10-Jul-12 5:03am    
Try some actual full url path at place inputString . If it is working then change logic for that. Copy inputString & paste it in browser & look whether you are getting image or not.
Umashankar Yadav 10-Jul-12 5:23am    
Getting the Image
pradiprenushe 10-Jul-12 5:47am    
Does this line gives you syntax error or not?
8 th line
li.InnerHtml =
Umashankar Yadav 10-Jul-12 7:31am    
No it does not gives any error link is working properly and data is getting but Image is not displayed.

1 solution

please first check your inputString gives write url like for image and then
"<img src='" + inputString + "' width='" + "100" + "' height='" + "75" + "' runat="'""+"Server"+"'s/>"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900