473,809 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingManagerB ase Problem

My newly added row will not become current.

I have several textboxes bound to a DataGrid1 and a couple of buttons
including 'btnNewRecord'. The datagrid is bound to a table in a
dataset.

What happen is that btnNewRecord adds a new row to DataGrid1 as
expected, however the active row does not move to the newly added row!
What am I missing?

Here is pertainent code...

===== Code 1 ===
Public Class frmJobCustomer
Inherits frmForm1

[" Window Form Designer generated code "]

Private _bmb As BindingManagerB ase

Private Sub btnNewRecord_Cl ick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnNewRecord.Cl ick
_bmb.AddNew()
End Sub

Private Sub DataGrid1_Curre ntCellChanged(B yVal sender As Object,
ByVal e As System.EventArg s) Handles DataGrid1.Curre ntCellChanged
Dim _currentRow As Integer = DataGrid1.Curre ntCell.RowNumbe r
Me.DataGrid1.Se lect(_currentRo w)
_bmb.Position = _currentRow
End Sub

Private Sub btnCancelChange s_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnCancelChange s.Click
_bmb.CancelCurr entEdit()
End Sub

Private Sub btnSaveChanges_ Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnSaveChanges. Click
_bmb.EndCurrent Edit()
End Sub

Private Sub JobCustomer_Loa d(ByVal sender As System.Object, ByVal e

As System.EventArg s) Handles MyBase.Load

'Get ds from the DAL
Dim JobCustomerDB As New DALCL.Tables
localDsTables1 = JobCustomerDB.G etDaJobCustomer
Me.DataGrid1.Da taSource = localDsTables1. tblJobCustomer

Call CreateBindings( )
End Sub

Private Sub CreateBindings( )
' Add control configuratioins to the collection
Me.lblpkJobCust omerId.DataBind ings.Add("Text" ,
Me.localDsTable s1.tblJobCustom er, "pkJobCustomerI d")
Me.txtJobNumber .DataBindings.A dd("Text",
Me.localDsTable s1.tblJobCustom er, "JobNumber" )
Me.txtJobDescri ption.DataBindi ngs.Add("Text",
Me.localDsTable s1.tblJobCustom er, "JobDescription ")
Me.txtShopPSI.D ataBindings.Add ("Text",
Me.localDsTable s1.tblJobCustom er, "ShopPsi")
Me.chkApproved. DataBindings.Ad d("Checked",
Me.localDsTable s1.tblJobCustom er, "Approved")

_bmb = Me.BindingConte xt(Me.localDsTa bles1.tblJobCus tomer)
_bmb.Position = 0
End Sub

End Class
=== End Code 1 ===

I have also tried this code for the btnNewRecord with no success.

=== Code 2 ===
Private Sub btnNewRecord_Cl ick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnNewRecord.Cl ick

'Add a row and go to it
Me.BindingConte xt(Me.DataSet1. *Customers).Add New()
Me.BindingConte xt(Me.DataSet1. *Customers).Pos ition = _
Me.DataSet1.Cus tomers.Rows.Cou *nt - 1
End Sub
=== End Code 2 ====

I want to be able to edit the new row with my bound textboxes. What can
I do to correct the behavior and have the selected datagrid row become
the newly created row?

- Doug

Nov 21 '05 #1
1 1450
Doug,

When you show something, than delete all duplicates and try to not to use
all kind of synonimes of tables. At first sight I will see looking at what
you are showing that you are binding apples and pears.

However I made a little simple sample for you. Try that.

\\\needs a datagrid and two buttons on a form
Dim cma As CurrencyManager
Dim dv As DataView
Private Sub Form1_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim dt As New DataTable
Button1.Text = "New"
Button2.Text = "Accept"
dt.Columns.Add( "Name")
dt.LoadDataRow( New Object() {"Dough"}, True)
dt.LoadDataRow( New Object() {"Peter"}, True)
dt.LoadDataRow( New Object() {"Cor"}, True)
dv = dt.DefaultView
DataGrid1.DataS ource = dv
dv.AllowNew = False
dv.AllowEdit = False
cma = DirectCast(Bind ingContext(dv), CurrencyManager )
TextBox1.DataBi ndings.Add("Tex t", dv, "Name")
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
dv.AllowNew = True
cma.AddNew()
dv.AllowNew = False
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button2.Click
cma.EndCurrentE dit()
End Sub
///

I hope this helps a little bit?

Cor
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
7278
by: Peter Olcott | last post by:
www.halting-problem.com
28
5228
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
4
6276
by: Christopher Weaver | last post by:
How do I retrieve the position value after successfully finding the row that I'm looking for? I need to set BindingManagerBase.Position so that all of the controls on the form are synchronized. Is there another way of moving to a particular record within a dataset given the value of the key?
6
3818
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
4
1955
by: Joe | last post by:
can someone help me with this code (1) daNewEmployer.Fill(DsNewEmployer) (2) daNewEmployee.Fill(DsNewEmployer) (3)bmbEmployer = BindingContext(DsNewEmployer, "Employer") I am trying to fill a the bindingmanagerbase with two tables in the third line of code. However, it only takes two arguments, the dataset "DsNewEmployer" and the table "Employer". I need to add the "Employee" table to
4
1744
by: Jesse Villani | last post by:
I will get this eventually, I have a combobox on a form which is bound to a dataset and displays correct values in the list. When i select a value from the list, i check to see what is the current row in a bindingManagerBase object is in the selectedValue event handler code. I print out, on labels the following values: bmb.Count and bmb.Position where bmb is the bindingManagerBase object.
0
1074
by: johnb41 | last post by:
I have a simple form with textboxes displaying records from a dataset. To Add a record, i simply do this (successfully): ' bmb variable holds the me.bindingcontext(dataset, "table"), which returns a BindingManagerBase object Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
16
4932
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
4
1385
by: Dave | last post by:
I have a BindingManagerBase which is used witha stored precudure. When I try to execute the statement: this.BindingContext I get the error: System.ArgumentException was unhandled. Message="Child list for field table1 cannot be created." L. A. Jones
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.