Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2009, 01:55 AM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default Maybe there is a better way??

Hello everyone,

Okay so here is what i am looking into now:

PROFILE.ASPX // the profile page of my social network site

Code:
 
protectedvoid Page_Load()
{

string conString = WebConfigurationManager.ConnectionStrings["myconnection"].ConnectionString;     // okay here
DataContext db = newDataContext(conString); // seems simple enough...
var tMessages = db.GetTable<Messages>();  // getting into new territory but i still get it.
tMessages.Where(m => m.Read == 0);  // This is kinda neat but i want the number of items in the list who have the Read property set to 0 (for false) so i can make my link button say "you have {0} messages!"
 
// and i was taking a shot in the dark thinking i'd be using something similar to this, in the sense of using the Sum method.

tMessages.Sum(m => m.Read == 0); 
}
 
now i was thinking of posting this list of unread messages to the next page:

VIEWMESSAGES.ASPX

Code:
 
protectedvoid Page_Load()
{

if (Page.PreviousPage != null)
{
// I was thinking of making a property on the previouspage i could grab the value from via this page and this property holds the list of messages (preferably just the new ones like so:
 
// PreviousPage.Property
 
// if that is something a professional developer wouldnt agree with, then perhaps it would be better to repeat the process of getting the unread messages list and databind it to a gridview

}
}
 
now this line here:

Code:
 
tMessages.Where(m => m.Read == 0);
my understanding of it is "in the Messages table where all Read messages are 0 (false)
im not sure what the "greater than equals to is for" ( => )...

anyways thanks for reading my multipart question. :)
  #2 (permalink)  
Old March 9th, 2009, 08:34 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You will want to do something like this to get the count:

csharp Code:
var UnreadMessages =
      from m in db.Messages Where m.Read == 0
      Select m.UniqueID.Count();
 
Response.Write(UnreadMessages)

For info on Lambda expressions ( =>) go here:
http://www.developer.com/net/csharp/article.php/3598381

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #3 (permalink)  
Old March 9th, 2009, 11:43 AM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

awesome thanks dparsons, im going to try it now
  #4 (permalink)  
Old March 11th, 2009, 03:38 AM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

im thinking m.ID.Count() is supposed to be defined by me right?

because its saying that the method doesnt exist. just wanted to make sure im not missing a reference.

thanks doug :)
  #5 (permalink)  
Old March 11th, 2009, 04:14 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I haven't followed / read the entire discussion, but maybe you're missing a using statement for System.Linq?

using System.Linq;

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!
  #6 (permalink)  
Old March 11th, 2009, 09:41 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

forgot to post back here and saying i got it.

but yes thats exactly what i missed... i put that statement in the wrong file.. :P *doh*
 


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




All times are GMT -4. The time now is 08:14 PM.


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