I have a gridview with a list of my users (using the ASP.Net Membership and Profile providers) and I have managed to display all the fields I need. But the problem is that when I access the page that edits the profile of a user or I add a column to the gridview where it displays some field from the profile of the users, these are set as logged on.
Why is this? Can this be avoided?
I need to know the list of the users, and who is really logged in at the moment, but with this problem I can't know because all users are marked as logged in.
Here's the code of my grid view.
<asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserName"
OnRowCreated="gvUsers_RowCreated" OnRowDeleting="gvUsers_RowDeleting"
Font-Size="8pt" Width="700px" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowSorting="true">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField HeaderText="Usuario" DataField="UserName"/>
<asp:HyperLinkField HeaderText="E-mail" DataTextField="Email"
DataNavigateUrlFormatString="mailto:{0}" DataNavigateUrlFields="Email" />
<asp:TemplateField HeaderText="No. Cliente">
<ItemTemplate>
<asp:Label ID="lblCustormerID" runat="server" Text='<%# Profile.GetProfile(Eval("UserName").ToString()).Contacts.CustomerID %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Creado" DataField="CreationDate"
DataFormatString="{0:MM/dd/yy h:mm tt}" />
<asp:BoundField HeaderText="Ultima Actividad" DataField="LastActivityDate"
DataFormatString="{0:MM/dd/yy h:mm tt}" />
<asp:CheckBoxField HeaderText="Activo" DataField="IsApproved"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:CheckBoxField>
<asp:CheckBoxField HeaderText="En Línea" DataField="IsOnline"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:CheckBoxField>
<asp:HyperLinkField Text="<img src='../images/edit.gif' border='0' />"
DataNavigateUrlFormatString="EditUsers.aspx?UserName={0}"
DataNavigateUrlFields="UserName" />
<asp:ButtonField CommandName="Delete" ButtonType="Image"
ImageUrl="~/images/delete.gif" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>No se encontraron usuarios.</EmptyDataTemplate>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
I have spent hours googling for an answer without any luck, so your help is greatly appreciated.
Thanks in advance!