Hi
I am trying to bind the combobox in wpf from the datatable.
but unable to bind.
Please send me the code .
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gaurish KumarPosted Oct 28, 2009, 5:30 AM
Put the combobox in xaml like this
<ComboBox Grid.Row="1" Height="23" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" Margin="143,12,185,0" Name="comboBox1" SelectedValue="{Binding Path=id}" DisplayMemberPath="username" SelectedValuePath="id" VerticalAlignment="Top" />
And write the code in xaml.cs in windows_loaded event
UserDataSet userdataSet = new UserDataSet();
UserDataSetTableAdapters.UserTableAdapter userTableAdapter = new UserDataSetTableAdapters.UserTableAdapter();
comboBox1.ItemsSource = userTableAdapter.GetData();
// provide any datasource I am using tableadapter
Shilpa SharmaPosted Oct 28, 2009, 5:52 AM
Thanks for the quick reply
Work great!