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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:06:36+00:00 2026-05-28T11:06:36+00:00

I am displaying categories in a dropdown list for adding products. When a product

  • 0

I am displaying categories in a dropdown list for adding products. When a product is to be added, you will have to select a category and Create Product or Update a previous product.

But my problem is that I get the following error:

No mapping exists from object type
System.Web.UI.WebControls.DropDownList to a known managed provider
native type.

Database Diagram:
Database Diagram Picture

ASPX.:

    <p>Kategori</p>
    <asp:DropDownList ID="DDCategories" runat="server" AutoPostBack="True">
    </asp:DropDownList>

ASPX.CS.:

       protected void Page_Load(object sender, EventArgs e)
        {
            //Dropdown Category Names From DB
            if (!IsPostBack)
            {
                string sConstr = ConfigurationManager.ConnectionStrings["LLcateringConnectionString"].ConnectionString;
                SqlConnection Conn = new SqlConnection(sConstr);
                DataTable dt = new DataTable("tbl");

                using (Conn)
                {
                    Conn.Open();
                    SqlCommand comm = new SqlCommand("SELECT Name FROM Category", Conn);
                    SqlDataAdapter da = new SqlDataAdapter(comm);
                    da.Fill(dt);
                }

                DDCategories.DataSource = dt;
                DDCategories.DataTextField = "Name";
                DDCategories.DataBind();
            }
    }

 protected void BtnUpdateOrCreate_Click(object sender, EventArgs e)
    {
        // Text in fields has to exist, if they are requierd
        if (!string.IsNullOrWhiteSpace(TxtName.Text) /*&&
            !string.IsNullOrWhiteSpace(TxtDescription.Text)*/)
        {
            // New the DataAccess and have all the parameteres here
            DataAccess dataAccess = new DataAccess();
            dataAccess.AddParameter("@Name", TxtName.Text);
            dataAccess.AddParameter("@Category_ID", DDCategories);
            dataAccess.AddParameter("@Description", TxtDescription.Text.ToNewline(false));
            dataAccess.AddParameter("@UnitPrice", TxtPrice.Text);
            dataAccess.AddParameter("@DiscountUnitPrice", TxtUnitDiscount.Text);

            if (isCreate)
            {
                // Insert query
                dataAccess.Execute(@"INSERT INTO [Product] ([Name], [Category_ID], [UnitPrice], [DiscountUnitPrice], [Description])
                                     VALUES (@Name, @Category_ID, @UnitPrice, @DiscountUnitPrice, @Description)
                                    INNER JOIN dbo.Product ON dbo.Category.ID = dbo.Product.Category_ID 
                                    ORDER BY [Name]
                                    WHERE id = @id");
            }
            else
            {
                // Update query
                dataAccess.AddParameter("@id", MenuID);
                dataAccess.Execute(@"UPDATE [Product]
                                    SET [Name] = @Name, [Category_ID] = @Category_ID, [UnitPrice] = @UnitPrice, [DiscountUnitPrice] = @DiscountUnitPrice, [Description] = @Description
                                    WHERE id = @id");
                                    //UPDATE [Product]
                                    //SET [Name] = @Name, [Category_ID] = @Category_ID, [UnitPrice] = @UnitPrice, [DiscountUnitPrice] = @DiscountUnitPrice, [Description] = @Description
                                    //INNER JOIN dbo.Product ON dbo.Category.ID = dbo.Product.Category_ID 
                                    //ORDER BY [Name]
                                    //WHERE id = @id");
            }

            // Redirects to list
            Response.Redirect(Request.Url.AbsolutePath);
        }
        else
            LitStatus.Text = "Hey så indtast da noget!";
    }
  • 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-28T11:06:37+00:00Added an answer on May 28, 2026 at 11:06 am

    check this line
    dataAccess.AddParameter("@Category_ID", DDCategories);
    and replace with
    dataAccess.AddParameter("@Category_ID", DDCategories.SelectedValue)

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

Sidebar

Related Questions

I have an ASPX page .In the Top i am displaying 5 categories (Ex
I have 4 categories within the 'Default Category' category. Currently by default Magento is
I am displaying a list of categories in ASC order.OTHERS is also one of
My app has a set of categories. A category can have sub-categories. DirectoryCategoryController is
I have a quick question in regards to the approach to displaying products on
I'm displaying my categories using the wp_list_categories function like so: <?php wp_list_categories('selected=6&title_li='); ?> Now,
I have Rails 3.1.2 app with a hierarchical relationship that looks like this: Categories
I have the following template. I want to display the categories with a comma
I'm going to have cells with different subviews depending on which category is chosen.
I've got a Repeater displaying a list of Countries, and nested within this is

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.