Problem populating GridView!

Discussion in 'ASP .Net' started by Jeff, Oct 11, 2006.

  1. Jeff

    Jeff Guest

    Hey

    asp.net 2.0

    I have this GridView in my web page. My problem is that it get populated
    with all the fields of the MembershipUser class. I thought only UserName
    would be displayed, but it displays all fields

    <asp:GridView ID="gvwOnline" runat="server">
    <Columns>
    <asp:ButtonField DataTextField="UserName" />
    </Columns>
    <EmptyDataTemplate>No users are online</EmptyDataTemplate>
    </asp:GridView>

    MembershipUserCollection onlineUsers = Membership.GetAllUsers();
    gvwOnline.DataSource = onlineUsers;
    gvwOnline.DataBind();

    Any suggestions?
     
    Jeff, Oct 11, 2006
    #1
    1. Advertising

  2. If you want to only grab specific columns, you must set the "AutoGenerateColumns"
    to false:

    > <asp:GridView ID="gvwOnline" runat="server" AutoGenerateColumns="false">
    > <Columns>
    > <asp:ButtonField DataTextField="UserName" />
    > </Columns>
    > <EmptyDataTemplate>No users are online</EmptyDataTemplate>
    > </asp:GridView>


    More information here:

    http://msdnwiki.microsoft.com/en-us...webcontrols.gridview.autogeneratecolumns.aspx

    -dl

    --
    David Longnecker
    Web Developer
    http://blog.tiredstudent.com

    > Hey
    >
    > asp.net 2.0
    >
    > I have this GridView in my web page. My problem is that it get
    > populated with all the fields of the MembershipUser class. I thought
    > only UserName would be displayed, but it displays all fields
    >
    > <asp:GridView ID="gvwOnline" runat="server">
    > <Columns>
    > <asp:ButtonField DataTextField="UserName" />
    > </Columns>
    > <EmptyDataTemplate>No users are online</EmptyDataTemplate>
    > </asp:GridView>
    >
    > MembershipUserCollection onlineUsers = Membership.GetAllUsers();
    > gvwOnline.DataSource = onlineUsers;
    > gvwOnline.DataBind();
    > Any suggestions?
    >
     
    David R. Longnecker, Oct 11, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    8,875
    =?Utf-8?B?RWx0b24gVw==?=
    Mar 1, 2006
  2. =?Utf-8?B?YmlsbCB0aWU=?=

    problem populating gridView on dropDownList

    =?Utf-8?B?YmlsbCB0aWU=?=, Apr 26, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    620
    Vlad Iliescu
    Apr 27, 2006
  3. Mike P
    Replies:
    0
    Views:
    483
    Mike P
    Jun 2, 2006
  4. Replies:
    6
    Views:
    513
  5. Jeff
    Replies:
    1
    Views:
    427
Loading...

Share This Page