databinding in winforms to listbox

M

Martin

Hi,

I have been working with asp.net and have decieded to make the transition to
winforms.
At present the difference in databinding between the two enviroments is
throwing me.

I am trying to databind a dataset to a listbox control. I have the following
code. The dataset is not a strongly typed dataset and was created with the
sql application block. It has two colums "KnowledgeBaseName" and
"KnowledgeBaseID"

lbSelectKB.DataSource = ds
lbSelectKB.DisplayMember = "KnowledgeBaseName"
lbSelectKB.ValueMember = "KnowledgeBaseID"

Can anybody please help me out..
can I have two items bound to the control.
I am unsure of how to instigate databinding..

many thanks in advance

cheers

martin.
 
C

ClayB [Syncfusion]

I think you likely need to be binding to a DataTable in your DataSet.
(DataSets hold DataTables and Relations. DataTables hold DataColumns).

lbSelectKB.DataSource = ds.Tables("MyKnowledgeBaseTable")

======================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
M

Martin

cheers..




ClayB said:
I think you likely need to be binding to a DataTable in your DataSet.
(DataSets hold DataTables and Relations. DataTables hold DataColumns).

lbSelectKB.DataSource = ds.Tables("MyKnowledgeBaseTable")

======================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

transition
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top