NEWBIE: problem populating a GridView

J

Jeff

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
 
J

Jeff

Fixed, I had forgotten this if statement:
if (e.Row.RowType == DataControlRowType.DataRow)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top