Advertisement

07.21.2008 at 05:15AM PDT, ID: 23581495
[x]
Attachment Details

DataGridView adds blank row to dataset - how do I get it to ignore the blank row?

Asked by pigparent in ADO.Net Class Library, Microsoft Visual Basic.Net

Tags: Microsoft, Visual Studio, 2008, Winforms development

Experts, I have an issue that puzzles me.  In my datagridview (the topic of a few questions from me over the last week) users can add rows and everything is now working dandy.  The only trouble is that it also adds the new blank row at the bottom of the datagridview to my dataset as well, and this is undesirable.

The row is not completely blank, since I am adding primary key data programmatically once a user enters a new row (snippet below).  Since it has that data, the datagridview/bindingsource considers it to be a valid record.  I don't expect anyone to write my code for me...do you have any tips on how I should attempt to block that row without any other effects (such as failing to save the other rows or pestering the user with a message)?

Thanks in advance!Start Free Trial
1:
2:
3:
4:
5:
Private Sub dgvEncumbr_RowValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvEncumbr.RowValidating
        With dgvEncumbr.CurrentRow
            .Cells("PONo").Value = textPONo.Text
        End With
    End Sub
[+][-]07.21.2008 at 05:32AM PDT, ID: 22049803

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 07:42AM PDT, ID: 22050922

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 08:30PM PDT, ID: 22056261

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: ADO.Net Class Library, Microsoft Visual Basic.Net
Tags: Microsoft, Visual Studio, 2008, Winforms development
Sign Up Now!
Solution Provided By: MijaeDjinn
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.22.2008 at 04:26AM PDT, ID: 22058131

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628