Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / November 2004

Tip: Looking for answers? Try searching our database.

Display rows in datagrid in textboxes -- nulls kill it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Beverley - 23 Nov 2004 18:50 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.