title: How to Bind LINQ result variable into Gridview in asp.net
body: <p>I have written a simple LINQ which is retrieving username with roles from membership .Now as per my need i have to bind and display it into gridview but its not happening ...here is my code...</p>
  
  <p>This is my gridview code...</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
      &lt;asp:GridView ID="GridView1" runat="server"&gt;
      &lt;/asp:GridView&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is my server side code with LINQ query..</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      BindGridviewData();      
  
  }
  
  
  
  protected void BindGridviewData()
  {
      var roles = from MembershipUser u in Membership.GetAllUsers()
                  select new
                  {
                      user = u,
                      roles = Roles.GetRolesForUser(u.UserName)
                  };
  
      GridView1.DataSource = roles;
      GridView1.DataBind();
  
  }
  </code></pre>
  
  <p>But its not happening  ....Any help will be appreciated...</p>