Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 28th, 2008, 10:57 PM
Registered User
 
Join Date: Mar 2008
Location: , , Malaysia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default BindingNavigator show 2 extra when add new row

Greeting.
I'm working on my vb.net 2005 project and linking to SQL server 2000 for my database.

I have a master user form which having a bindingnavigator binding to a binding source control to user class's datatable.
I got a problem on the bindingnavigator. when I'm trying to addnew record. the bindingnavigator's positionitem textbox shows 2 extra new record as it suppose to have only 1 new row increase.

below is my code to add new row. Please advice.



''my Form's sub
      Private Sub frmUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim success As Boolean

            success = mUser.LoadAll
            If Not success Then
                Throw New Exception("Failed to Load All record.")
            Else
                BindingSource1.DataSource = mUser.dataTable
                BindingNavigator1.BindingSource = BindingSource1
                Bind() 'Bind to all my input textboxes

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As system.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
        mUser.AddNew()
    End Sub


''my user class's addnew function
    Public dataTable As DataTable = New DataTable
    Public currentRow As DataRow = Nothing

    Public Overridable Sub AddNew()
        currentRow = dataTable.NewRow()
        dataTable.Rows.Add(currentRow)

    End Sub


Public Overridable Function LoadAll() As Boolean
        Try

            Dim success As Boolean = False

            Dim cmd As SqlCommand = New SqlCommand
            cmd.Connection = New SqlConnection(gConnStr)
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "[SP000STDUSERLoadAll]"

            If dataTable.Rows.Count > 0 Then
                currentRow = dataTable.Rows(0)
                success = True
            End If

            Return success

        Catch ex As Exception

        End Try
    End Function





Reply With Quote
  #2 (permalink)  
Old March 28th, 2008, 11:22 PM
Registered User
 
Join Date: Mar 2008
Location: , , Malaysia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem had been solved. I deleted the default addnew button in the bindingnavigator and created my own. and then copy back all the code to my new button then it work fine. Would it because of there are some hiding method in the default button? like RemoveCurrent method for delete button?

Anyone can tell?

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
add extra header in datagrid p330418 ASP.NET 2.0 Professional 1 April 9th, 2008 11:30 AM
Extra redundant row after export to excel yukijocelyn ASP.NET 2.0 Basics 0 October 2nd, 2007 09:00 PM
show columns with same ID in the same row yuvalk SQL Server 2005 4 February 2nd, 2007 07:46 PM
show/hide row(s) eugz Beginning PHP 0 March 19th, 2006 10:10 PM
Add Column to Show Time KennethMungwira ADO.NET 1 December 2nd, 2003 12:30 PM



All times are GMT -4. The time now is 03:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.