473,657 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource Removing Current Row

Greetings

I have a a simple application with 1 form. On my form I use a
BindingSource to bind a database table to a "table (gridDataView)" (one
in the database, one on my form, 2 different types of tables).

I want to remove the current row I tried :

GrantsBindingSo urce.RemoveCurr ent();

this removes it from the list on the form, but does not remove it from
the database, so I tried this :

GrantsBindingSo urce.RemoveCurr ent();
GrantsBindingSo urce.EndEdit();

this also did not work, so finally I uesd the following :

DataRowView drv = (DataRowView)gr antsBindingSour ce.Current;
AcroDataSet.Gra ntsRow row = (AcroDataSet.Gr antsRow)drv.Row ;
grantsTableAdap ter.Delete(row. login, row.application , row.level);
grantsBindingSo urce.RemoveCurr ent();

This "works" but seems like a lot to just remove the current record, is
there a "better" way? some way I can use the BindingSource natively and
remove the item from the "list" and the database at the same time?

thanks in advance
troy
May 28 '07 #1
3 23050
Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a DataSet
or DataTable, it sets the state of the row to delete. You have to pass that
DataSet/DataTable to a data adapter in order to have the database updated.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"msnews.microso ft.com" <tr*******@gmai l.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Greetings

I have a a simple application with 1 form. On my form I use a
BindingSource to bind a database table to a "table (gridDataView)" (one in
the database, one on my form, 2 different types of tables).

I want to remove the current row I tried :

GrantsBindingSo urce.RemoveCurr ent();

this removes it from the list on the form, but does not remove it from the
database, so I tried this :

GrantsBindingSo urce.RemoveCurr ent();
GrantsBindingSo urce.EndEdit();

this also did not work, so finally I uesd the following :

DataRowView drv = (DataRowView)gr antsBindingSour ce.Current;
AcroDataSet.Gra ntsRow row = (AcroDataSet.Gr antsRow)drv.Row ;
grantsTableAdap ter.Delete(row. login, row.application , row.level);
grantsBindingSo urce.RemoveCurr ent();

This "works" but seems like a lot to just remove the current record, is
there a "better" way? some way I can use the BindingSource natively and
remove the item from the "list" and the database at the same time?

thanks in advance
troy
May 28 '07 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a
DataSet or DataTable, it sets the state of the row to delete. You have
to pass that DataSet/DataTable to a data adapter in order to have the
database updated.

So, am i doing this incorrectly? How do I pass the DataSet associated
with my BindingSource to a dataadapter?

Thanks
troy
May 28 '07 #3
Troy,

The way you are doing it is right. I was just explaining why that way
was right.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Troy Bull" <tr*******@gmai l.comwrote in message
news:et******** ******@TK2MSFTN GP03.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
>Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a
DataSet or DataTable, it sets the state of the row to delete. You have
to pass that DataSet/DataTable to a data adapter in order to have the
database updated.


So, am i doing this incorrectly? How do I pass the DataSet associated
with my BindingSource to a dataadapter?

Thanks
troy
May 28 '07 #4

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

Similar topics

2
6325
by: Bryan Shaw | last post by:
I have a Windows app I am developing in VS .NET 2005 that is required to periodically look at the data in a table in an MS SQL 2000 database. The data is being changed from an external stored procedure. All I want the app to do is refresh the data bound controls on a timer tick. I am using the new TableAdapter and BindingSource controls as recommended in the Help. I am at a loss as to the method to use to get the BindingSource to do...
0
4148
by: Geoff | last post by:
Hi folks Calling BindingSource.ResetCurrentItem() is changing the BindingSource.Position in a way I don't understand. If I'm understanding the docs correctly, ResetCurrentItem() should simply trigger an event which causes controls to refresh with the values of the current item with the index BindingSource.Position. This is not what I'm seeing.
1
3106
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the list. The problem happens when: - I use such a BindingList as DataSource for a BindingSource. - Add this BindingSource as DataSource for a DataGridView. - And go to the NewRow and add a new row in the DataGridView.
5
7839
by: Rob Dob | last post by:
Hi, I have two c# Winforms. the first form has a datagridview who's datasource is a bindingsource. when you double click on a datagridview row it then opens my second form, which has some databound controls, text boxes that are bound to another bindingsource. Both bindingsources are bound to the same dataset, and contain the same information. Within my second forms Load method I fill my dataset that is bound to my bindingsource with...
6
14973
by: BD | last post by:
Hi, I have a "Cancel" button on a form to cancel any changes in the current item with the code BindingSource1.CancelEdit but this don't restore the older's values that had been changed. The BindingSource.DataSource is a type of BindingList<MyClass>. What's I'm doing wrong? 's BD
2
3454
by: jehugaleahsa | last post by:
Hello: I have a BindingSource that has its DataSource set to a BindingList<Customerwhere Customer is a business object that manipulates a DataRow. All changes to a Customer instance, update a DataTable via DataRow. It is fairly easy to add a new item to the BindingSource. However, removing is a different story. I need to be able to know when an item is removed because I would like to call Delete on the DataRow. I need
1
180
by: Cdude | last post by:
I need to access the current row of the bindingsource. I need to assign that row to a DataRow is this possible.The reason i want to do this is that i have a switch statement that needs the "AccessLevel" value out of the current row.
5
4931
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This will make it clear to the user that they have to create a new item first before they start working. This needs to be an easy process because there are many, many forms.
2
16830
by: Eric B. | last post by:
I could use a little clarification on using a BindingSource with my DataTable. As I understand it, the BindingSource sits between my data source (a DataTable) and DataGridView and any changes made to it is reflected in the other two? Now if that is so, how should I access the elements of my DataTable? I need to make decisions on what Rows to remove based on comparing the values of the elements. Should I access the individual elements via...
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
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...
0
8602
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
7316
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1601
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.