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 8438063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:36:17+00:00 2026-06-10T07:36:17+00:00

I am populating states DDL using the country DDL public static IEnumerable bindcountry() {

  • 0

I am populating states DDL using the country DDL

public static IEnumerable bindcountry()
{
    var countries = from c in getdata().Descendants(("country"))
                    orderby (string)c.Element("name")
                    select (string)c.Element("name");
    return countries;
}

public List<string> GetStatesByCountry(string CountryName)
{

    var query = from user in getdata().Descendants("country")
                where user.Element("name").Value == CountryName
                from t in user.Descendants("text")
                select t.Value;
    return query.ToList();
}

foreach (var VARIABLE in ProfileMasterDAL.bindcountry())
{
    if (VARIABLE.ToString().Contains(DropDownList1.SelectedItem.Text))
    {
        var query = from row in ProfileMasterDAL.bindcountry()
                    where row.(ProfileMasterDAL.GetStatesByCountrys(DropDownList1.SelectedItem.Text))
                    select row;

        DropDownList2.DataSource = query;
        DropDownList2.DataBind();
    }
}

The problem is I am unable to define WHERE clause and equals here I am getting an error:

Could not find an implementation of the query pattern for source type
‘System.Collections.IEnumerable’. ‘Where’ not found. Consider
explicitly specifying the type of the range variable ‘row’.

  • 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-06-10T07:36:19+00:00Added an answer on June 10, 2026 at 7:36 am

    You say that you are trying to populate a DropDownList with the names of the States for a given Country and it looks like that logic is in your foreach loop. It also looks like your foreach loop is doing a lot of unnecessary work.

    It’s iterating through all the Country names when it really only needs to find one of those country names. It also then iterates again through the country names looking for the states.

    You should be able to throw out that entire foreach loop and instead use this:

    var query = ProfileMasterDAL.GetStatesByCountry(DropDownList1.SelectedItem.Text);
    DropDownList2.DataSource = query;   
    DropDownList2.DataBind();   
    

    Your GetStatesByCountry method returns just the states that belong to the passed in Country name, so you should just be able to call that, get the names of just those States, and then assign them to your DropDownList.

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

Sidebar

Related Questions

I am populating my database from online data using the loop like (simplified, with
so as the title states, using the following code I have got it populating
Im populating a GridView from List so am forced to use TemplateField controls to
im populating the data in the combo box using dataset tables...with some table name..now
I'm populating my select box using the query shown below: <%=f.select :acoustic, options_for_select(User.includes(:roles).where( :roles
I am populating a class using Linq to SQL. What I am trying to
I am populating my Google chart using JSON currently, but I need to customize
I'm populating a CheckBoxList from database table. As per requirement, all the values should
I am populating the list view with data I am getting from a JSON
I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton

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.