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

  • Home
  • SEARCH
  • 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 8870517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:45:11+00:00 2026-06-14T17:45:11+00:00

I have 6 dropdownlist that are populated from a sqldatasource. I also have another

  • 0

I have 6 dropdownlist that are populated from a sqldatasource. I also have another sqldatasource that returns some rows. What I want to do is to go through each row of the second datasource and select that value in my dropdowns. So if second datasource contains three rows it would select the appropriate value in the first three dropdownlist and set the others to “N/A” for example.

here is some pseudo code I thought of

protected void fileattributes_ItemDataBound(object sender, ListViewItemEventArgs e)
{
        DropDownList kw1 = (DropDownList)e.Item.FindControl("keyw1");
        DropDownList kw2 = (DropDownList)e.Item.FindControl("keyw2");
        DropDownList kw3 = (DropDownList)e.Item.FindControl("keyw3");
        DropDownList kw4 = (DropDownList)e.Item.FindControl("keyw4");
        DropDownList kw5 = (DropDownList)e.Item.FindControl("keyw5");
        DropDownList kw6 = (DropDownList)e.Item.FindControl("keyw6");

        DropDownList[] array = { kw1, kw2, kw3, kw4, kw5, kw6 };

        for(int i = 0; i<sqldatasource2.length;i++)
        {            
              array[i].SelectedItem.Text = sqldatasource2.item    
        }

        foreach(Array a in array)
        {    
              if (a is null)
              {    
                   a.selecteditem.text = "N/A";
              }        
        }        
}    
  • 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-14T17:45:12+00:00Added an answer on June 14, 2026 at 5:45 pm
    DataSourceSelectArguments args = new DataSourceSelectArguments();
    DataView view = (DataView)SqlDataSource1.Select(args);
    DataTable dt = view.ToTable();
    
    DropDownList[] array = { kw1, kw2, kw3, kw4, kw5, kw6 };
    int i;
    for (i = 0; i < dt.Rows.Count;i++ )
    {
        array[i].SelectedItem.Text = dt.Rows[i][0].ToString();
    }
    
    // If array length (number of DropDowns) is greater than rows in datasource
    // Remaining Dropdowns will get text N/A --- Now i=dt.Rows.Count
    for (; i < array.Length; i++)
    {
        array[i].SelectedItem.Text = "N/A";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdownlist that is being populated from a database. That is working
I have a DropDownList that is populated from a datasource. After it is bound,
I have a DropDownList inside an UpdatePanel that is populated on postback from a
I have a DropDownList that gets populated from SQL on page load. A user
I have a DropDownList control that is populated with TimeZones from calling: ReadOnlyCollection<TimeZoneInfo> tzCollection;
I have a DropDownList which is populated using a sqldatasource, i.e., from database and
i have a dropdownlist that populates from the sql server database. populating the list
I have a dropdownlist that is being populated by a sql server, I am
I have a DropDownList that asks the user if he want to join the
I have an ASP.NET DropDownList control that retrieves the first and last name from

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.