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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gaurish Kumar108 reputationPosted Oct 28, 2009, 1:30 AM EDT
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 Sharma3 reputationPosted Oct 28, 2009, 1:52 AM EDT
Thanks for the quick reply
Work great!