Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 08, 2012 03:20 AM by Chen Yu - MSFT
Member
384 Points
315 Posts
May 04, 2012 02:22 AM|LINK
Hi,
Im showing 1 picture from each album with the code above:
<asp:ListView ID="lvCategorias" runat="server" DataSourceID="CategoriasSQLDS" DataKeyNames="codigo"> <emptydatatemplate> <table runat="server" style=""> <tr> <td> </td> </tr> </table> </emptydatatemplate> <itemtemplate> <li runat="server" style=""> <%--<img src="img/albums.png" style="height:37px" />--%> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/Public/fotos/" + Eval("foto") %>' Height="100" /> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "VerFotos.aspx?codigo_album=" + Eval("codigo") %>' CssClass="23uioy4"> <asp:Label ID="tituloLabel" runat="server" Text='<%# Eval("titulo") %>' CssClass="albums-titulo" /> </asp:HyperLink> </li> </itemtemplate> <layouttemplate> <div ID="itemPlaceholderContainer" runat="server" border="0" style=""> <ul ID="itemPlaceholder" runat="server"> </ul> </div> </layouttemplate> </asp:ListView> <asp:SqlDataSource ID="CategoriasSQLDS" runat="server" ConnectionString="<%$ ConnectionStrings:nutrisinalConnectionString %>" SelectCommand="SELECT * FROM ( SELECT Albums.titulo, Albums.codigo as album, Fotos.codigo_album, Fotos.codigo, Fotos.foto, Rnk = RANK() Over(Partition by Albums.codigo Order by Fotos.codigo DESC) FROM Fotos INNER JOIN Albums ON Fotos.codigo_album = Albums.codigo ) AS x WHERE Rnk = 1"> </asp:SqlDataSource>
What if i need to show 2 pics from each album. How would i do ? Thanks.
All-Star
117314 Points
7997 Posts
Moderator
MVP
May 04, 2012 02:33 AM|LINK
WHERE Rnk <=2
May 04, 2012 10:01 AM|LINK
Ok. And how do i show the album title and the 2 pics in the Listview ?
Contributor
3230 Points
668 Posts
May 04, 2012 10:26 AM|LINK
go to design view
at the top right corner of listview there is a right arrow
click on it
options displyed , in that select configure listview
select any layout you want and click on ok
May 04, 2012 10:29 AM|LINK
So im showing ONE pic in this part of the code:
<itemtemplate> <li runat="server" style=""> <%--<img src="img/albums.png" style="height:37px" />--%> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/Public/fotos/" + Eval("foto") %>' Height="100" /> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "VerFotos.aspx?codigo_album=" + Eval("codigo") %>' CssClass="23uioy4"> <asp:Label ID="tituloLabel" runat="server" Text='<%# Eval("titulo") %>' CssClass="albums-titulo" /> </asp:HyperLink> </li> </itemtemplate>
Do you know how to show a second image in the itemtemplate ?
Thanks
May 04, 2012 11:08 AM|LINK
if your query will contain two records
then automatically it will show two images with this code
May 04, 2012 11:11 AM|LINK
no it wont. ive tried.
May 04, 2012 12:06 PM|LINK
http://www.maconstateit.net/tutorials/aspnet40/ASPNET07/aspnet07-08.aspx
21569 Points
2493 Posts
Microsoft
May 08, 2012 03:20 AM|LINK
Hi xandeq,
Did you get the solution? If not, please go to Web Forms Data Controls forum, the experts here will help you deeply. Thanks for your understanding.
Thanks.
xandeq
Member
384 Points
315 Posts
Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 02:22 AM|LINK
Hi,
Im showing 1 picture from each album with the code above:
<asp:ListView ID="lvCategorias" runat="server" DataSourceID="CategoriasSQLDS" DataKeyNames="codigo"> <emptydatatemplate> <table runat="server" style=""> <tr> <td> </td> </tr> </table> </emptydatatemplate> <itemtemplate> <li runat="server" style=""> <%--<img src="img/albums.png" style="height:37px" />--%> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/Public/fotos/" + Eval("foto") %>' Height="100" /> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "VerFotos.aspx?codigo_album=" + Eval("codigo") %>' CssClass="23uioy4"> <asp:Label ID="tituloLabel" runat="server" Text='<%# Eval("titulo") %>' CssClass="albums-titulo" /> </asp:HyperLink> </li> </itemtemplate> <layouttemplate> <div ID="itemPlaceholderContainer" runat="server" border="0" style=""> <ul ID="itemPlaceholder" runat="server"> </ul> </div> </layouttemplate> </asp:ListView> <asp:SqlDataSource ID="CategoriasSQLDS" runat="server" ConnectionString="<%$ ConnectionStrings:nutrisinalConnectionString %>" SelectCommand="SELECT * FROM ( SELECT Albums.titulo, Albums.codigo as album, Fotos.codigo_album, Fotos.codigo, Fotos.foto, Rnk = RANK() Over(Partition by Albums.codigo Order by Fotos.codigo DESC) FROM Fotos INNER JOIN Albums ON Fotos.codigo_album = Albums.codigo ) AS x WHERE Rnk = 1"> </asp:SqlDataSource>What if i need to show 2 pics from each album. How would i do ?
Thanks.
limno
All-Star
117314 Points
7997 Posts
Moderator
MVP
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 02:33 AM|LINK
WHERE Rnk <=2
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
xandeq
Member
384 Points
315 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 10:01 AM|LINK
Ok. And how do i show the album title and the 2 pics in the Listview ?
tusharrs
Contributor
3230 Points
668 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 10:26 AM|LINK
go to design view
at the top right corner of listview there is a right arrow
click on it
options displyed , in that select configure listview
select any layout you want and click on ok
( Mark as Answer if it helps you out )
View my Blog
xandeq
Member
384 Points
315 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 10:29 AM|LINK
So im showing ONE pic in this part of the code:
<itemtemplate> <li runat="server" style=""> <%--<img src="img/albums.png" style="height:37px" />--%> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/Public/fotos/" + Eval("foto") %>' Height="100" /> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "VerFotos.aspx?codigo_album=" + Eval("codigo") %>' CssClass="23uioy4"> <asp:Label ID="tituloLabel" runat="server" Text='<%# Eval("titulo") %>' CssClass="albums-titulo" /> </asp:HyperLink> </li> </itemtemplate>Do you know how to show a second image in the itemtemplate ?
Thanks
tusharrs
Contributor
3230 Points
668 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 11:08 AM|LINK
if your query will contain two records
then automatically it will show two images with this code
( Mark as Answer if it helps you out )
View my Blog
xandeq
Member
384 Points
315 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 11:11 AM|LINK
no it wont. ive tried.
tusharrs
Contributor
3230 Points
668 Posts
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 04, 2012 12:06 PM|LINK
http://www.maconstateit.net/tutorials/aspnet40/ASPNET07/aspnet07-08.aspx
( Mark as Answer if it helps you out )
View my Blog
Chen Yu - MS...
All-Star
21569 Points
2493 Posts
Microsoft
Re: Show 2 pics from each album using SELECT Rank Over Partition by
May 08, 2012 03:20 AM|LINK
Hi xandeq,
Did you get the solution? If not, please go to Web Forms Data Controls forum, the experts here will help you deeply. Thanks for your understanding.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store