Saturday, 31 August 2013

Listbox Databinding in wpf

Listbox Databinding in wpf

Hi i am binding the data coming form database to listboxitems, below is
the code
public void load_users()
{
RST_DBDataContext conn = new RST_DBDataContext();
List<TblUser> users = (from s in conn.TblUsers
select s).ToList();
Login_Names.ItemsSource = users;
}
and in in xaml there is the below code
<ListBox Name="Login_Names" ItemsSource="{Binding Path=UserName}"
HorizontalAlignment="Left" Height="337" Margin="10,47,0,0"
Padding="0,0,0,0" VerticalAlignment="Top" Width="156">
but it does not works, it shows table name but i need to see the usernames
coming from table, there is column called UserName in TblUsers
Thanks in Advance

No comments:

Post a Comment