Reputation: 1058
I need to add a Company Name field that is associated with the logins. Later on I need to incorporate that into my existing admin screens for reporting.
I just can't figure out how to get this done. I have tried the add a column to the Membership table and modifying the stored procs but the column will not show up.
Here is the code of my admin page that I need to modify.
<%@ Page Language="C#" MasterPageFile="~/admin.master" %>
<%@ Register TagPrefix="dc" TagName="alphalinks" Src="~/alphalinks.ascx" %>
<script runat="server">
private void Page_PreRender()
{
if (Alphalinks.Letter == "All")
{
Users.DataSource = Membership.GetAllUsers();
}
else
{
Users.DataSource = Membership.FindUsersByName(Alphalinks.Letter + "%");
}
Users.DataBind();
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="c" Runat="Server">
<!-- #include file="_nav.aspx -->
<table class="webparts">
<tr>
<th>Users by Name</th>
</tr>
<tr>
<td class="details" valign="top">
<!-- #include file="_nav3.aspx -->
User Name filter:
<dc:alphalinks runat="server" ID="Alphalinks" />
<br />
<br />
<asp:GridView runat="server" ID="Users" AutoGenerateColumns="false"
CssClass="list" AlternatingRowStyle-CssClass="odd" GridLines="none"
>
<Columns>
<asp:TemplateField>
<HeaderTemplate>User Name</HeaderTemplate>
<ItemTemplate>
<a href="edit_user.aspx?username=<%# Eval("UserName") %>"><%# Eval("UserName") %></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="email" HeaderText="Email" />
<asp:BoundField DataField="comment" HeaderText="Comments" />
<asp:BoundField DataField="creationdate" HeaderText="Creation Date" />
<asp:BoundField DataField="lastlogindate" HeaderText="Last Login Date" />
<asp:BoundField DataField="lastactivitydate" HeaderText="Last Activity Date" />
<asp:BoundField DataField="isapproved" HeaderText="Is Active" />
<asp:BoundField DataField="isonline" HeaderText="Is Online" />
<asp:BoundField DataField="islockedout" HeaderText="Is Locked Out" />
</Columns>
</asp:GridView>
</td>
</tr></table>
</asp:Content>
I appreciate any help on this please.
Thank you,
Steve
Upvotes: 4
Views: 5455
Reputation: 13230
Edit: Don't modify the stored procs or the tables created with the membership provider. This is asking for trouble. What you need to do is add a Profile Provider, which extends the standard user information.
Original Answer: Have a read of this article by Scott Guthrie: http://weblogs.asp.net/scottgu/archive/2006/01/10/435038.aspx It is about the Table Profile Provider, which is a lot better than the out of the box one.
This one too: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
Upvotes: 3
Reputation: 37074
Steve, are you returning a custom MembershipUser
, that you have constructed with the appropriate values, from the custom MembershipProvider
that would need to be implemented in order to do this?
If not, then you will need to do so.
If so, you will need to cast the results from Membership, as it's return type is a stock Membership user, even if you are returning a derived type.
something along the lines of..
Users.DataSource = Membership.GetAllUsers().Cast<MyMembershipUser>();
Upvotes: 2