Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 27th, 2010, 05:08 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old May 27th, 2010, 05:17 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #3 (permalink)  
Old May 27th, 2010, 05:34 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #4 (permalink)  
Old May 27th, 2010, 06:00 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #5 (permalink)  
Old May 28th, 2010, 03:04 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #6 (permalink)  
Old May 28th, 2010, 03:27 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #7 (permalink)  
Old May 28th, 2010, 04:19 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:43 PM.


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