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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:02:55+00:00 2026-05-15T14:02:55+00:00

Very simple problem…but weird results. Im just trying to fill a drop down list

  • 0

Very simple problem…but weird results.
Im just trying to fill a drop down list in c#

protected void Page_Load(object sender, EventArgs e)
{
    if (!(Page.IsPostBack))
    {
        LoadDropDowns();            
    }
}

protected void LoadDropDowns()
{
    ddlVendor.DataSource = BL.GetAllVendors();
    ddlVendor.DataTextField = "VendorName";
    ddlVendor.DataValueField = "VendorName";
    ddlVendor.DataBind();
}

BL.GetAllVendors is simply a static class which does this:

public static List<Vendor> GetAllVendors()
{
    return DL.GetAllVendors();     
}

And DL.GetAllVendors is also static class (the data layer) that goes out builds the List:

public static List<Vendor> GetAllVendors()
{
    using(SqlConnection con = new SqlConnection(connString))
    {
        //use sproc
        SqlCommand cmd = new SqlCommand("selAllVendors", con);
        cmd.CommandType = CommandType.StoredProcedure;

        //temporary storage of list of vendors
        List<Vendor> lv = new List<Vendor>();

        con.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        //continue as long as we have vendors
        while (reader.Read())
        {
            //instantiate a vendor
            Vendor v = new Vendor((string)reader["VendorName"]);
            //add them to the list
            lv.Add(v);
        }
        //clean the reader
        reader.Close();
        reader = null;

        //return that list
        return lv;
    }
}

The vendor class is simple:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Vendor
/// </summary>
namespace TK.Objects
{
    public class Vendor
    {
        private string VendorName { get; set; }

        public Vendor(string vn)
        {
            VendorName = vn;
        }
    }
}

I know my sproc is correct because I did a debug / watch and I see it pulls off two records “All”, and “Microsoft”.

And the sproc is simple:

CREATE PROCEDURE selAllVendors
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

      SELECT
        Vendor AS VendorName,
        1 as SortOrder
    FROM 
        Vendor
    UNION ALL
    SELECT
        'All' AS VendorName,
        0 as SortOrder
    ORDER BY 
        SortOrder,
        Vendor  
END
GO

But when I run this code I get an error:

System.Web.HttpException was unhandled by user code
  Message=DataBinding: 'TK.Objects.Vendor' does not contain a property with the name 'VendorName'.
  Source=System.Web
  ErrorCode=-2147467259
  WebEventCode=0
  StackTrace:
       at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName)
       at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format)
       at System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource)
       at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
       at System.Web.UI.WebControls.ListControl.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at _Default.LoadDropDowns() in c:\Users\Documents\Visual Studio 2010\WebSites\T\Default.aspx.cs:line 26
       at _Default.Page_Load(Object sender, EventArgs e) in c:\Users\Documents\Visual Studio 2010\WebSites\T\Default.aspx.cs:line 17
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: 

What am I missing here?

  • 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-15T14:02:56+00:00Added an answer on May 15, 2026 at 2:02 pm

    the VendorName property on your Vendor class has to be public rather than private.

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

Sidebar

Related Questions

Very simple problem, but can't seem to solve it. I'm probably just not thinking
Trying to solve a very simple problem using mvvm-light, but after days of sifting
I have a very simple problem, but I just can't figure it out. My
This is probably a very simple problem but I'm trying to create an array
I have a very simple problem and a solution that will work, but I'm
This may be a very simple problem, but I couldn't find an answer googleing
I have a very simple problem but cannot find a nice solution. I have
I am sure this is a very simple problem, but I am new to
This seems like a very simple problem, but I cannot get a scrollbox to
I have a very simple problem. I'm trying to make an ajax call using

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.