开发者

use html to get image and create link from database

开发者 https://www.devze.com 2023-02-06 07:20 出处:网络
I have a column in my database that stores images that are links, when i populate them in a gridview on my asp.net page I wa开发者_StackOverflow社区nt it to display the image as a link but when i did

I have a column in my database that stores images that are links, when i populate them in a gridview on my asp.net page I wa开发者_StackOverflow社区nt it to display the image as a link but when i did it i just get the text below.

   <a href="http://www.url.com/url/url/url/url.html"><img src="http://www.url.com/url/url/url/url.jpg"></a> 

My goal is to have a list of the images and when a user clicks the image they will go to another page. This is a start of my page, and i was attempting to use a gridview but now I am not sure what to do


Don't save markup

Instead just save a URL. In your case two of them since one points to *.html and the other to *.jpg. Or just without extensions if they're always the same except for the extensions. This way you can easily change your markup later and still use the same data from the DB.

But apart from this fact of not saving non-data in DB you could at least provide some relevant code you're using. We'd much easier tell you where you're doing it wrong.

Using GridView

The problem you're having are column templates. Check this link out and see how you can customize the display of a particular column in a GridView. Essentially you will have to provide your own template and do whatever you please with your DB data.

0

精彩评论

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