Wrox Programmer Forums
|
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 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 February 26th, 2009, 08:03 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old February 27th, 2009, 04:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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)
 
Old February 27th, 2009, 03:43 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old March 4th, 2009, 03:54 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old March 4th, 2009, 05:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
Old March 4th, 2009, 05:21 PM
Friend of Wrox
 
Join Date: Mar 2008
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
 
Old March 4th, 2009, 05:25 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
Old March 4th, 2009, 05:32 PM
Friend of Wrox
 
Join Date: Mar 2008
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...
 
Old March 4th, 2009, 05:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!





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





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