views:

42

answers:

2

How do I bind a textbox to one to many valued columns.

my table: id name statusid typeid assignerid ...

I would like to bind all these to textboxes. Some of the options are:

i.make joins and form resultset accordingly<1, tom, new, query, george> ii.bind the sub table values to combobox and set selected value property accordingly

are there any other techniques?

A: 

If you're using .NET 4, look into the DataGrid control. It's a tabular list control that supports editing similar to a spreadsheet UI.

<DataGrid ItemsSource="{Binding MyItems}" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
        <DataGridComboBoxColumn Header="Status"
                                ItemsSource="{StaticResource Statuses}"
                                DisplayMemberPath="Name"
                                SelectedValuePath="ID"
                                SelectedValueBinding="{Binding StatusID}" />
    </DataGrid.Columns>
</DataGrid>
Josh Einstein
A: 

I found another solution using Entity framework. EF is too cool!

Sarath
Even though Josh's solution was apt as a WPF beginner I realised EF can do better as I progressed!
Sarath