Databinding techniques
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, q开发者_StackOverflow中文版uery, george> ii.bind the sub table values to combobox and set selected value property accordingly
are there any other techniques?
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>
I found another solution using Entity framework. EF is too cool!
精彩评论