Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 February 26th, 2009, 08:03 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 LoginView

okay so basically i use the login control to make my account on my website (aside from the issue that i can not log in with that account more than once...), i want to use the gridview to show all the members. the problem is it shows everything, security answer/question, is online, provider, etc... i just want to pull out the isonline and UserName columns but idk what table the data is being held in i looked at the tables folder in the database manager on VWD and there is no table i see with those column names. is there a default name to the table the logincontrol uses?

if anyone can show me how to display:

Member Name IsOnline

in a grid view. or anything like that. let me know...maybe i should use a different control? my thanks in advance
  #2 (permalink)  
Old February 27th, 2009, 04:22 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

The GridView is a good control for this scenario; it isn't related to where you get the data from; it just displays what you send to it.

However, the way you get that data is important; you shouldn't access the database directly, but instead rely on the Membership API. It has a convenient GetAllUsers method that returns a collection of Membership instances. You can call that method from on ObjectDataSource and then bind to a GridView like this:
Code:
 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllUsers" 
      TypeName="System.Web.Security.Membership">
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" 
           AutoGenerateColumns="False">
  <Columns>
    <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" 
                  SortExpression="UserName" />
    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
    <asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate" 
                  SortExpression="LastActivityDate" />
    <asp:CheckBoxField DataField="IsOnline" HeaderText="IsOnline" ReadOnly="True" 
                  SortExpression="IsOnline" />
  </Columns>
</asp:GridView>
Hope this helps,

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!
The Following User Says Thank You to Imar For This Useful Post:
iceman90289 (February 27th, 2009)
  #3 (permalink)  
Old February 27th, 2009, 03:43 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

thanks Imar. it works and looks better than my last gridview attempt
  #4 (permalink)  
Old March 4th, 2009, 03:54 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

now, extending this for development purposes. it would be great if i could show the applicationName attribute from the database, in this gridview. the reason is that i need to add the appname in the web.config file so i can log in with registered accounts but i dont know the value and i cant look at the database file from the school computer. i plan on taking off this feature when people use this site, they wont need to know the appname, but for now i do :)

thanks to anyone here that can help a brotha out
  #5 (permalink)  
Old March 4th, 2009, 05:12 PM
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

Hi again,

You can get the ApplicationName from the configured provider:

Label1.Text = Membership.Provider.ApplicationName;

Membership.Provider returns the active provider, while Membership.Providers returns all configured providers.

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 4th, 2009, 05:21 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

Imar you rock. when you get your free book can i have it too? haha just kidding. thanks :D
  #7 (permalink)  
Old March 4th, 2009, 05:25 PM
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 free book?

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!
  #8 (permalink)  
Old March 4th, 2009, 05:32 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

yeah, doesnt wrox give away free books to the top forum members? or something...
  #9 (permalink)  
Old March 4th, 2009, 05:33 PM
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

Yes, they do. But Wrox authors are excluded from that program......

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!
 


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
scope issue with LoginView iceman90289 ASP.NET 3.5 Basics 3 February 5th, 2009 08:57 PM
Trying to use a LoginView within a Repeater BSpeerTX ASP.NET 2.0 Basics 2 April 23rd, 2007 10:57 AM



All times are GMT -4. The time now is 05:24 PM.


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