NEWBIE: problem populating a GridView



ASP.NET 2.0

I have a GridView control in my webpage. In this GridView's
gridUsers_RowDataBound am I having problem populating the controls with info
from the datasource -

This code is the problem:
MembershipUser user = (MembershipUser)e.Row.DataItem;
The user object doesn't get a MembershipUser value, it gets the value NULL.

Here are some of the code from my webpage so can get an overview of what I'm
doing:
<asp:GridView ID="gridUsers"
runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gridUsers_RowDataBound" >

protected void Page_Load(object sender, EventArgs e)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
gridUsers.DataSource = allUsers;
gridUsers.DataBind();
}

protected void gridUsers_RowDataBound(object o, GridViewRowEventArgs e)
{
MembershipUser user = (MembershipUser)e.Row.DataItem; **** < this code
don't work
ProfileCommon userProfile = Profile.GetProfile(user.UserName);
/*
Here I will put code that manually populate the columns in the
GridView with info from the Profile object
*/
}

any suggestions on what I should do to populate the user object with the
MembershipUser value?

Jeff


.



Relevant Pages

  • Re: NEWBIE: problem populating a GridView
    ... I have a GridView control in my webpage. ... The user object doesn't get a MembershipUser value, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Passing parameters to gridview
    ... into the text boxes are valid dates, but even when my code captures that ... they are not valid dates it seems like it still tries to populate the ... gridview and in doing so gives me the error 'Conversion failed when ... Rather than wrestling with date validation I suggest you get a good ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Gridivew Summary of all columns
    ... This code sample at ASPNet101.com shows how to add one column - just do the ... David Wier ... I need to populate a gridview. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Row Item in DataView - OnRowDatabound event
    ... In my new application, I'm using a DataView to populate the Gridview, since ... "Object Reference not set to an instance of the object' error when it gets ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Rookie question : Writing edited form data (gridview) to XML
    ... Your first step "Populate a GridView from an xml file" could be a simple as ... databinding the GridView control to an XmlDataSource control (if you are ... "Write contents of GridView to new xml file". ...
    (microsoft.public.dotnet.xml)

Loading