0

How to dynamically generate the below image tag with links from the database.Number of images should be the number of items in the database.

Can we use listview or repeater to achive this.If yes how ??

     <div class="social-icons_box">

       <div class="label_social">
         Get Social
       </div>
       <a href="www.youtube.com"><img src="images/youtube.jpg" /></a>
       <a href="www.twitter.com"><img src="images/twitter.jpg" /></a>
       <a href="www.facebook.com"><img src="images/facebook.jpg" /></a>
       .
       .
       .
   </div>

The database structure of the image table is as follows

Image_Id      Image_Type    Image_File    Image_Location         Img_Url

 1             jpeg          youtube      images/youtube.jpg   www.youtube.com

 2             jpeg          facebook     images/fb.jpg          www.fb.com            

 3             jpeg          twitter      images/twter.jpg       www.twitter.com

2 Answers 2

3

in the repeater Item template use the code something like this

 <a href='<%# Eval("Img_Url")%'><img src='<%# Eval("Image_Location")%>' /></a>

Bind this repeter with the Datssource which returns the Image _URL and Image_Location columns

Sign up to request clarification or add additional context in comments.

Comments

1
  <asp:DataList runat="server" ID="DataList1" RepeatDirection="Vertical">
                                        <ItemTemplate>
                                        <a id="avalue" runat="server" href='<%# Eval("Img_Url")%'> <asp:Image ID="lmgElementImage" runat="server" ImageUrl='<%#Bind("Image_Location") %>' Width="24px" Height="26px"></asp:Image></a>

                                        </ItemTemplate>
                                    </asp:DataList>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.