I'm trying to do pretty much exactly what is described here:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q992q
I have a datagrid which is bound to some data (surprise). Then I have some textboxes,
which I want to display the current data shown in the datagrid. The guts of the code that
accomplishes this is:
'Get the table
Dim dt As DataTable = TCE.db.TheDataset.Personnel
'Set the data grid to this table (filtered to the current sub tab)
Me.DataGrid1.DataSource = dt.Select("SubTabID = " & iSubTab.ToString)
'bind the textboxes
With Me.txtCategory.DataBindings
.Clear()
.Add("Text", Me.DataGrid1.DataSource, "Category")
End With
'follow same procedure for all other text boxes......
My problem is if any of the data is null, it dies. It cannot seem to handle a null in
databinding. The grid handles it fine, but if (for example) the Category is null for one
of the rows, it won't update the text boxes to that row at all (not even the other
non-null rows). I can click on any other row, as long as it is fully filled out.
The above code is only run once, so I'm not sure where I should be checking for nulls, or
whether I should just mangle my SQL statement by wrapping IsNull around each and every
field (please don't tell me to do it this way!) :)
Thanks much
Beverley
Beverley - 23 Nov 2004 19:17 GMT
Changed this:
Me.DataGrid1.DataSource = dt.Select("SubTabID = " & iSubTab.ToString)
To this:
dt.DefaultView.RowFilter = "SubTabID = " & iSubTab.ToString
Me.DataGrid1.DataSource = dt
And now it seems to be working fine. Gah!
> I'm trying to do pretty much exactly what is described here:
> http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q992q
[quoted text clipped - 28 lines]
>
> Beverley