Jump to content

Add and populate a combo box in a .NET web service

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
Hey all

I currently have a text box where by the user would enter a product name, in order to save user error a combo box would be more appropriate.

How do I add a combo box in place of this text box? The user will be using the combo box to select a product and submit a bid on this product to the database. The combo box should list all the product names in the database but the productID is to be inserted along with the bid amount and customerID into a table in my database

How would I go about doing this?

Regards
Akin

#2
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
It almost seems like a drop down list would be more appropriate and you can bind the list with the values that you need. I think you're going to run into too much trouble trying to generate check boxes on the fly during render. You can just grab all the products you need from the database and bind the drop down list.
-CDG10620
Software Developer

#3
aakinn

aakinn

    Newbie

  • Members
  • PipPip
  • 24 posts
Silly question but how exactly would I bind the data. The DB is a sdf attached to the project where a table called products is located

I have looked under the combo box properties and guessing I need to use the DataSource property something like this but its not quite picking up the Data binding

this.comboBox1.DataSource = Products.ID;
this.comboBox1.DisplayMember = "Product Name";

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
DataSource and then use the DataBind() method.
-CDG10620
Software Developer