Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, im trying to fill a ComboBox with an entire Collumn from my database but I don't want it to do with a DataSet or something like that. I want it via Code

Can someone plz help
Don't know what to do
VB
 Dim combo As ComboBox
        combo = frmRD.cboNomCoop
frmRD.cboNomCoop.Items.Add("")
Posted
Updated 11-Apr-13 8:43am
v3
Comments
Richard C Bishop 11-Apr-13 14:22pm    
DataSet is used in coding. It is just a collection(or an in-memory cache according to MSDN) of data retrieved from a datasource. DataTable is a table of retrieved data. How else are you going to get data?
Maciej Los 11-Apr-13 16:15pm    
Why don't you put it as an answer?
Richard C Bishop 11-Apr-13 16:33pm    
Well, I asked a question in my comment and did not want it to be misconstrued as abuse.
Maciej Los 11-Apr-13 16:44pm    
Abuse? No, it's not abuse. It's very good answer and i uses your comment in my solution. I hope you're not angry for me...
Richard C Bishop 11-Apr-13 16:46pm    
No worries, just as long as the information is out there.

TesterJSR wrote:
im trying to fill a ComboBox with an entire Collumn from my database but I don't want it to do with a DataSet or something like that. I want it via Code


It's not work like that! Why? See Ryan comment.

richcb wrote:

DataSet is used in coding. It is just a collection(or an in-memory cache according to MSDN) of data retrieved from a datasource. DataTable is a table of retrieved data. How else are you going to get data?
 
Share this answer
 
I d go with


Create A DataTable

VB
for each rows as Datarow in Gridview1.Datarow
Dim cValue as String=ctype(rows,"LabelorTextbox",textbox).text \\you are getting the cell value here

\\insert the value to your created Datatable here


Next


combobox.datasource=your created datatable
combobox.displaymember=your datatable column name or id 
combobox.valuemember=your datatable value column name or id 
combobox.databind


This code has not been tested but the logic tested in my own applications million times ;) i hope it helps you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900