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...
This is my gridview code...
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
And here is my server side code with LINQ query..
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();
}
But its not happening ....Any help will be appreciated...
Here example shows binding (employee details) with the condition employee age >=20
Check out this link to get more ideas
This works fine
var result = from c in objDataContext.Employees
where c.EmployeeAge >= 20
select c;
List<Employee> lstEmployee = result.ToList();
gridviewEmp.DataSource = lstEmployee;
gridviewEmp.DataBind();
Getting started with LINQ to SQL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With