newbie: GridView problem

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

  1. Jeff

    Jeff Guest

    Hey

    asp.net 2.0

    I've got only one column in my GridView (see code below), but when I run
    it... I see more columns in the GridView. These are the columns I see:
    - UserName
    - ProviderName
    - IsOnlne
    - LastPasswordChangedData
    - PasswordQuestion
    - IsLockedOut
    - Comment
    - UserName (again, but this time not as a buttonfield)
    - Email
    - CreationData
    - IsApproved
    - lastLockoutData
    - LastLoginDate
    - LastActivityDate

    <asp:gridview ID="gvwUsers" runat="server">
    <Columns>
    <asp:ButtonField HeaderText="UserName" DataTextField="UserName" />
    </Columns>
    </asp:gridview>

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

    I want only columns specified in the <Columns> section to be displayed.

    What am I doing wrong here?

    Jeff
    Jeff, Oct 26, 2006
    #1
    1. Advertising

  2. Set the AutoGenerateColumns property of your GridView to false.
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogeneratecolumns.aspx

    Jeff wrote:
    > Hey
    >
    > asp.net 2.0
    >
    > I've got only one column in my GridView (see code below), but when I run
    > it... I see more columns in the GridView. These are the columns I see:
    > - UserName
    > - ProviderName
    > - IsOnlne
    > - LastPasswordChangedData
    > - PasswordQuestion
    > - IsLockedOut
    > - Comment
    > - UserName (again, but this time not as a buttonfield)
    > - Email
    > - CreationData
    > - IsApproved
    > - lastLockoutData
    > - LastLoginDate
    > - LastActivityDate
    >
    > <asp:gridview ID="gvwUsers" runat="server">
    > <Columns>
    > <asp:ButtonField HeaderText="UserName" DataTextField="UserName" />
    > </Columns>
    > </asp:gridview>
    >
    > private MembershipUserCollection allUsers = Membership.GetAllUsers();
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > gvwUsers.DataSource = allUsers;
    > gvwUsers.DataBind();
    > }
    >
    > I want only columns specified in the <Columns> section to be displayed.
    >
    > What am I doing wrong here?
    >
    > Jeff
    Flinky Wisty Pomm, Oct 26, 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. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,942
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  2. Jeff
    Replies:
    1
    Views:
    1,783
  3. verci
    Replies:
    4
    Views:
    605
    verci
    Aug 19, 2006
  4. Vik
    Replies:
    1
    Views:
    509
  5. HeavyMetal

    GridView RowCommand problem: GridView Nested in Repeater

    HeavyMetal, Aug 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    774
    HeavyMetal
    Aug 8, 2006
Loading...

Share This Page