Click here to Skip to main content
16,013,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to know can we bind an Image/Images to a Literal Control, If Yes can anyone show me some examples or links on hoe to achieve that?

Thanks,
Chetan.
Posted

You can't really, the Literal just pumps out text to the HTML form. You could use it to create an image control with a path, but there are better ways of doing that, such as the Image web control or the HTML img tag.
 
Share this answer
 
Comments
fjdiewornncalwe 16-May-11 17:59pm    
Correct. I have run into the situation once or twice where a literal was a better solution than an Image. I can't remember exactly why, but it does work quite well to do this and simply write an html img tag to the literal.
Keith Barrow 17-May-11 19:19pm    
The literal is occasionally better for adding and img tag, but like you I have forgotten when!
u can use a data binding function binding your image for example

DataTable dt = new DataTable();
if(dt.rows.count > 0)
{
for (int i = 0 ; i <=dt.rows.count -1 ; i++)
{
}
}
 
Share this answer
 
Comments
phil.o 1-Dec-15 16:53pm    
Please, avoid textspeak on this forum, and use proper capitalization.
And enclose your code blocks between <pre> tags. Thanks :)
u can use a data binding function binding your image for example

DataTable dt = new DataTable();
if(dt.rows.count > 0)
{
   for (int i = 0 ; i <=dt.rows.count -1 ; i++)
  {
       <img src\"images/\" + dt.rows[i]["Pic"].ToString()+ "/>";
   }
}
 
Share this answer
 
Comments
Richard Deeming 1-Dec-15 12:28pm    
Two "answers" to a question that was posted and solved over four years ago, neither of which add anything to the discussion.

Keep that up, and you'll get kicked off the site.

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