databinding in winforms to listbox

  • Thread starter Thread starter Martin
  • Start date Start date
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.
 
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
 
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
 
Back
Top