开发者

Databinding techniques

开发者 https://www.devze.com 2023-01-13 18:46 出处:网络
How do I bind a textbox to one to many valued columns. my table: id name statusid typeid assignerid ...

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号