开发者

binding textboxes to a table

I have two tables that are related开发者_JAVA技巧 to each other in a 1-1 relationship (each row in the main table has exactly one corresponding row in the second table).

I also have a winform in which I'd like to show the main table in a datagridview, and for each row selected in the grid to show the fields of the corresponding row of the second table in various textboxes below the grid.

I know how to bind a datagridview to a datatable. But I'm not sure about binding several textboxes to a single row in the related datatable. I don't know what is the best way to implement it.

I'm writing in VB.Net (but can read some code in C#), using VS2008.

Any help, hints or ideas will be welcomed. Thanks.


Best way to do it is that instead of using two tables, use a join and get result in a single table, bind that table to gridview, and hide columns which you don't want to display to user. And then use cell click event of gridview and then get the index of selected row and then use

txtBoxName.Text = GridViewName["col_name",e.RowIndex].Value.ToString();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜