Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2010, 05:08 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default View Pics according photoAlbumOwner

Hello once again,
In the PhotoAlbums/Default.aspx page I have put the hyperlink around user name
Code:
<asp:HyperLink ID="HyperLink2" runat="server"><asp:Label ID="lblUserName" runat="server" Text="" ForeColor="Red" /></asp:HyperLink>
and in code behind I have bound the NavigateUrl property as follows
Code:
HyperLink2.NavigateUrl = "ViewPhotoAlbum.aspx?UserName=" & photoAlbumOwner
Now I wanna create a page ViewPhotoAlbums.aspx such that whenever the uses name is clicked in Default.aspx page then it shows all the pics uploaded by the particular user regardless of the albums that user has.

For this again I am using the ListView to achieve the same.
Code:
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" 
                DataSourceID="LinqDataSource1" onitemcreated="ListView1_ItemCreated">
                
                <LayoutTemplate>
                    <ul class="itemContainer">
                        <li ID="itemPlaceholder" runat="server" />
                        </ul>
                    </LayoutTemplate>
                <ItemTemplate>
                <li>
						<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' ToolTip='<%# Eval("ToolTip") %>' />
						<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                        &nbsp;
					  <asp:Button ID="DeleteButton" CommandName="Delete" runat="server" Text="Delete" /><br /><br />
				</li>
                </ItemTemplate>
            </asp:ListView>
and the LinqDataSource is modified as follows
Code:
<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="DataContext" TableName="Pictures" 
                    Where="UserName == @UserName" EnableDelete="True">
                    <WhereParameters>
                        <asp:QueryStringParameter Name="UserName" QueryStringField="UserName" 
                            Type="String" />
                    </WhereParameters>
                </asp:LinqDataSource>
But as UserName is not defined in the table Picture so I get the error
No property or field 'UserName' exists in type 'Picture'
And if I change the table name then Image1, Description etc. will not be accessible. So how we can filter the pics on the basis of UserName Query String?

Thank You
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 27th, 2010, 05:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can either store the user name with each picture as well, or use a JOIN to join Albums and Pictures together.

For the latter option, you need to do some digging into LINQ and how its JOIN syntax works. Recommended resources to get started with:

http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
http://www.wrox.com/WileyCDA/WroxTit...470041811.html

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 27th, 2010, 05:34 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hi,
Thanks for the links these are worth watching.
The first link provides the lot of programming code which can be applied in code behind. But I am trying to filter the records based on the QueryString in the LinqdataSource itself. So how I should integrate that code behind codes in the aspx page?
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 27th, 2010, 06:00 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

My oh my, do you ever Google to try to answer these questions yourself before you post here???

The LinqDataSource only enables to query one table at a time. Thus if you want to use a JOIN, use a LINQ query in Code Behind.

Alternatively, skip the JOIN and use a Where clause on the LinqDataSource control dotting into the PhotoAlbum:

Where='it.PhotoAlbum.UserName = "Imar"'

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 28th, 2010, 03:04 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Code:
where='it.PhotoAlbum.UserName = "Imar"'
It worked fine but if use the code without it then also it works fine, so what is significance of it here?
Well Thank you for the help...
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 28th, 2010, 03:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Looks like someone is not searching Google or Bing before they ask questions here.

Is there a reason why you keep asking questions you can answer yourself with some research? I am not your free on-line encyclopedia, you know.... Also, by researching yourself you learn a lot more than just the answer to this question.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 28th, 2010, 04:19 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Quote:
by researching yourself you learn a lot more than just the answer to this question.
I do agree with you. Anyways thanks a lot.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent - Send mail with plain view and html view ashish.dadhwal ASP.NET 2.0 Professional 0 November 27th, 2008 01:49 AM
uploading pics dhoward VB.NET 2002/2003 Basics 4 April 29th, 2008 01:54 PM
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Problems with loading external pics into an IFrame nancy Classic ASP Databases 2 April 26th, 2005 10:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.