Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have 5 records in ImageGallery table with three fileds like ImgId, Img1, Img2. Now I need to bind the Images from mssql to Repeater control based on Id using slideshow purpose. In these I have empty values available. I need to display only those columns have images not empty values.

Ex:

Id Img1, Img2
-------------------------------
1 ~\Gallery\1.jpg ~\Gallery\2.jpg
2 ~\Gallery\3.jpg
3 ~\Gallery\4.jpg
4 ~\Gallery\5.jpg
5


XML
<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Img1") %>' />
    </ItemTemplate>
</asp:Repeater>

<asp:Repeater ID="Repeater2" runat="server">
    <ItemTemplate>
        <asp:Image ID="Image2" runat="server" ImageUrl='<%# Eval("Img2") %>' />
    </ItemTemplate>
</asp:Repeater>


Thanks in advance.
Posted
Updated 30-Oct-14 1:47am
v2

Try This...

C#
Text='<%#string.IsNullOrEmpty(Convert.ToString(Eval("Img1")))?"NUllEmpty":
Eval("Img1")%>'
 
Share this answer
 
v2
Comments
Member 10021658 30-Oct-14 8:07am    
Dear Aajmot,

Thanks for your reply.

I have to tired this way Visible='<%# Eval("Img1") != string.Empty %>'
Visible='<%# Eval("Img2") != string.Empty %>'

In these slideshow is working very fine but empty values also sliding.
Is it correct way?
/\jmot 30-Oct-14 8:38am    
Your Code..
Visible Property only select True or False Value..

Visible='<%# String.IsNullOrEmpty(Eval("Img2"))%>'


/\jmot 30-Oct-14 8:34am    
Replace the Empty image with Default Image.
/\jmot 30-Oct-14 8:36am    
like this..Text='<%#string.IsNullOrEmpty(Convert.ToString(Eval("Img1")))?"DefaultImage Path goes here":
Eval("Img1")%>'

Or

seems it's for the slide show ,so select the data from database where column Img not equal to Empty or null
Display a default image for those columns have empty values

ImageUrl='<%#(Eval("Img2")=="") ? "images/Default_Image.png":Eval("Img2") %>'
 
Share this answer
 
Search in google like image slide show and binding
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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