Bind to Roles.GetRolesForUser

Discussion in 'ASP .Net' started by mazdotnet, Sep 13, 2007.

  1. mazdotnet

    mazdotnet Guest

    Hi,

    I have a GridView that I want to bind user roles to

    gvUserRoles.DataSource = Roles.GetRolesForUser("Username");
    gvUserRoles.DataBind();

    How can access the roles using

    <asp:GridView ID="gvUserRoles" runat="server"
    AutoGenerateColumns="false">
    <Columns>
    <asp:TemplateField HeaderText="Roles">
    <ItemTemplate>
    Something like this???? <%#
    Eval("RoleName")%>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    Thanks
    M.
    mazdotnet, Sep 13, 2007
    #1
    1. Advertising

  2. On Sep 13, 2:43 am, mazdotnet <> wrote:
    > Hi,
    >
    > I have a GridView that I want to bind user roles to
    >
    > gvUserRoles.DataSource = Roles.GetRolesForUser("Username");
    > gvUserRoles.DataBind();
    >
    > How can access the roles using
    >
    > <asp:GridView ID="gvUserRoles" runat="server"
    > AutoGenerateColumns="false">
    > <Columns>
    > <asp:TemplateField HeaderText="Roles">
    > <ItemTemplate>
    > Something like this???? <%#
    > Eval("RoleName")%>
    > </ItemTemplate>
    > </asp:TemplateField>
    > </Columns>
    > </asp:GridView>
    >
    > Thanks
    > M.


    Hi, try <%# Container.DataItem.ToString() %>

    http://msdn2.microsoft.com/en-us/library/8h930x07.aspx
    Alexey Smirnov, Sep 13, 2007
    #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?QmVuIFIu?=

    Roles.IsUserInRole maps call to GetRolesForUser... Why?

    =?Utf-8?B?QmVuIFIu?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    876
    Steven Cheng[MSFT]
    Mar 24, 2006
  2. Nathan Sokalski
    Replies:
    2
    Views:
    454
    Nathan Sokalski
    Aug 5, 2008
  3. Nathan Sokalski
    Replies:
    2
    Views:
    1,572
    Nathan Sokalski
    Aug 9, 2008
  4. JaiPrakash Sharma

    Roles.GetRolesForUser(UserName) returning zero-dimension array

    JaiPrakash Sharma, Jan 30, 2008, in forum: ASP .Net Security
    Replies:
    1
    Views:
    218
    Misbah Arefin
    Feb 4, 2008
  5. Nathan Sokalski
    Replies:
    2
    Views:
    980
    Nathan Sokalski
    Aug 5, 2008
Loading...

Share This Page