 |
| 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
|
|
|
|

February 26th, 2009, 08:03 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
|
|
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
|
|

February 27th, 2009, 04:22 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

February 27th, 2009, 03:43 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
|
|
thanks Imar. it works and looks better than my last gridview attempt
|
|

March 4th, 2009, 03:54 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
|
|
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
|
|

March 4th, 2009, 05:12 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

March 4th, 2009, 05:21 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
|
|
Imar you rock. when you get your free book can i have it too? haha just kidding. thanks :D
|
|

March 4th, 2009, 05:25 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
My free book?
Imar
|
|

March 4th, 2009, 05:32 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
|
|
yeah, doesnt wrox give away free books to the top forum members? or something...
|
|

March 4th, 2009, 05:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yes, they do. But Wrox authors are excluded from that program......
Imar
|
|
 |