Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:17:25+00:00 2026-05-23T15:17:25+00:00

public ActionResult DownloadMembers() { MembershipUserCollection users = Membership.GetAllUsers(); var grid = new WebControls.GridView(); grid.DataSource

  • 0
public ActionResult DownloadMembers()
{
    MembershipUserCollection users = Membership.GetAllUsers();
    var grid = new WebControls.GridView();
    grid.DataSource = from members in users  // the users gives error
                      select new
                      {
                          Name = members.FirstName, // This doesn't works
                          Email = members.Email     //  This doesn't works
                      };
    grid.DataBind();
    Response.ClearContent();
    Response.AddHeader("content-disposition", "attachment; filename=" + "Members" + ".xls");
    Response.ContentType = "application/excel";
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    grid.RenderControl(htw);
    Response.Write(sw.ToString());
    Response.End();
    return RedirectToAction("Index");
}

Hi The above query downloads all the details from the membership table into CSV format for ms excel, it gives an error on users which is:

Could not find an implementation of the query pattern for source type ‘System.Web.Security.MembershipUserCollection’. ‘Select’ not found. Consider explicitly specifying the type of the range variable ‘members’.

Can any one guide me on how to get just the user email address and his/her name on the csv instead of getting all the details.

Edited: This works 🙂

grid.DataSource = from MembershipUser u in Membership.GetAllUsers()
                  select new
                  {
                      Firstname = u.UserName,
                      Email = u.Email                                   
                  };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:17:25+00:00Added an answer on May 23, 2026 at 3:17 pm
    grid.DataSource = from MembershipUser u in Membership.GetAllUsers()
                  select new
                  {
                      Firstname = u.UserName,
                      Email = u.Email                                   
                  };
    

    The above linqQuery works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public ActionResult myItems() { var dataContext = new RecordsDataContext(); MembershipUser myObject = Membership.GetUser(); string
public ActionResult Index(){ var dataContext = new DataEvidencijaDataContext(); MembershipUser myObject = Membership.GetUser(); string KorisnickoIme
public ActionResult ReadXMLDevices(int groupID) { var query = from k in XMLEntities.unassigneditems where k.DevOrAcc
public ActionResult AlbumList3( { AlbumService albumservice = new AlbumService(); var PagingViewModel = new PagingViewModel<Album>
Controller public ActionResult GetCategories() { var htmlText = new StringBuilder(); var scriptText = new
public ActionResult GeneratePdf(int id) { var labelRepository = new LabelRepository(); var label = labelRepository.GetLabel(id);
Here is my code: public ActionResult DeleteItem(int id) { using (var cont = new
// GET: /Product/Delete/5 public ActionResult Delete(int id) { var res = (from r in
My controller: [HttpPost] public ActionResult Deposit(DepositTicket dt) { using (var db = new MatchGamingEntities())
I have this controller: public ActionResult Details(String UserName) { using (var db = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.