Click here to Skip to main content
14,241,154 members
Rate this:
Please Sign up or sign in to vote.
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


<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
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try This...

Text='<%#string.IsNullOrEmpty(Convert.ToString(Eval("Img1")))?"NUllEmpty":
Eval("Img1")%>'
   
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
Rate this:
Please Sign up or sign in to vote.

Solution 2

Display a default image for those columns have empty values

ImageUrl='<%#(Eval("Img2")=="") ? "images/Default_Image.png":Eval("Img2") %>'
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Search in google like image slide show and binding
   

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100