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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:26:28+00:00 2026-06-14T22:26:28+00:00

I want to bind two column from database into dropdownlist. Here’s my code: SqlConnection

  • 0

I want to bind two column from database into dropdownlist. Here’s my code:

SqlConnection con=new SqlConnection(CommonRefference.Constr());
string query = "Select Id,Name+' ('+Distribution_name+') 'as Name1 from BR_supervisor  ";

SqlCommand cmd = new SqlCommand(query,con);
con.Open();

SqlDataReader reader = cmd.ExecuteReader();

while (reader.Read())
{
        DropDownList3.DataSource = query;
        DropDownList3.DataTextField = "name1";
        DropDownList3.DataValueField = "Id";
        DropDownList3.DataBind();
}
con.Close();

But it gives the following error

DataBinding: ‘System.Char’ does not contain a property with the name ‘name1’

How to do it? Anyone helps me is highly appreciated

  • 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-14T22:26:29+00:00Added an answer on June 14, 2026 at 10:26 pm

    Its Name1 not name1

    change this to

    DropDownList3.DataTextField = "Name1";
    

    EDIT:

    You are binding a string(query) to datasource here

    DropDownList3.DataSource = query;
    

    and string dont have a property with the name ‘name1’,so error

    SOLUTION :

    refer this,I have changed this for your requirement

    private void LoadDropDownList()
            {
                SqlConnection con=new SqlConnection(CommonRefference.Constr());
                string query = "Select Id,Name+' ('+Distribution_name+') 'as Name1 from BR_supervisor  ";
    
                SqlCommand cmd = new SqlCommand(query,con);
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
    
                DropDownList3.DataSource = reader ;
    
                DropDownList3.DataValueField = "Id";
                DropDownList3.DataTextField = "Name1";
    
                DropDownList3.DataBind();
    
                DropDownList3.Items.Insert(0, new ListItem("Select One", "0")); // Adds items to the DDL
                DropDownList3.Items.Insert(1, new ListItem("All Categories", "-1"));
    
                con.Close();
            }
    

    For more explanation refer this link Populate-ASP.NET-dropdownlist

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

Sidebar

Related Questions

I want to bind columns in a DataGridView to pull values from two different
Suppose I have two h:inputText components. I want to bind both of the text
I want to bind two lists to two columns of a Wpf DataGrid. How
I have a two column NSTableView that I want to populate with entries grabbed
I want to bind a column of my DataGrid to a nested property. I
Suppose in .aspx page their is dropdown in which i want to bind two
I need help in how to retrieve data from SQLite database and put into
I've created user control, the code for property which I want to bind is:
I want to bind a function to an event but I want to change
I want to bind a string value to a text box but only if

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.