hello everyone it is me again! i've got few problems too. i am deveoping an training software that's why i am asking lots of questions.i hope you help me. thanks in advance. my problems are as follows:
First of all: i have a register window that has a combobox. i have binded it an access datasource. the problem is when i select an item, it doesnt select. it writes System.data.Datarow.(i want it list names like mike,susan ect.)
how can i fix it? where is the problem?
public Register()
{
this.InitializeComponent();
Select();
}
public void Select()
{
DataView view;
OleDbConnection con = new OleDbConnection(connectionstring);
con.Open();
string sql = "Select * from UserInformation";
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "UserInformation");
view = ds.Tables[0].DefaultView;
RegCombo.ItemsSource = view;
con.Close();
}
XAML Code:
<ComboBox IsSynchronizedWithCurrentItem="True"
Margin="0,22.447,46.92,0" SelectedItem="{Binding Path=UserName}"
VerticalAlignment="Top" Height="29" Grid.Column="3" Grid.Row="1"
IsEditable="True" IsDropDownOpen="False" MaxDropDownHeight="266.666666666667"
FontSize="16" x:Name="RegCombo" FontWeight="Normal" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=UserName}"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>