473,769 Members | 7,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting rows from DataGrid

My DataGrid is bound to DataView as follow

DataGrid1.DataS ource = myDS.Tables("Cl ient_Consultant ").DefaultV iew

User can either delete all the rows in the DataGrid on by pressing "Delete All" button or provide Client_Consulat nt_ID and press "Delete" button to delete rows with that Client_Consulat nt_ID. My question is:

1. How can i delete all the rows on click of a button.

2. How can i remove all the rows with particular Client_Consulat nt_ID

thanx

Jul 21 '05 #1
2 1532
DataTable.Clear or loop through and call .Delete on each row - you'll do the
same for specific rows (call Delete on their respective index).

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Job Lot" <Jo****@discuss ions.microsoft. com> wrote in message
news:D3******** *************** ***********@mic rosoft.com...
My DataGrid is bound to DataView as follow

DataGrid1.DataS ource = myDS.Tables("Cl ient_Consultant ").DefaultV iew

User can either delete all the rows in the DataGrid on by pressing "Delete All" button or provide Client_Consulat nt_ID and press "Delete" button to
delete rows with that Client_Consulat nt_ID. My question is:
1. How can i delete all the rows on click of a button.

2. How can i remove all the rows with particular Client_Consulat nt_ID

thanx

Jul 21 '05 #2
That really depends on a few things, mainly if the grid is sortable or not.
If it is, the index is pretty much worthless b/c it won't be the same as it
appears in the grid.. Probably the simplest way is bind to a dataview, set
it's RowFilter property, then just delete those indexes directly. If you
filtered out 100 records so only one showed, called DataViewName[0].Delete,
you'd delete that row.

Is that what you need?

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Job Lot" <Jo****@discuss ions.microsoft. com> wrote in message
news:91******** *************** ***********@mic rosoft.com...
how wud i find index for rows with specified Client_Consulat nt_ID?

"William Ryan eMVP" wrote:
DataTable.Clear or loop through and call .Delete on each row - you'll do the same for specific rows (call Delete on their respective index).

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Job Lot" <Jo****@discuss ions.microsoft. com> wrote in message
news:D3******** *************** ***********@mic rosoft.com...
My DataGrid is bound to DataView as follow

DataGrid1.DataS ource = myDS.Tables("Cl ient_Consultant ").DefaultV iew

User can either delete all the rows in the DataGrid on by pressing
"Delete All" button or provide Client_Consulat nt_ID and press "Delete" button to
delete rows with that Client_Consulat nt_ID. My question is:

1. How can i delete all the rows on click of a button.

2. How can i remove all the rows with particular Client_Consulat nt_ID

thanx


Jul 21 '05 #3

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

Similar topics

1
4181
by: Junkguy | last post by:
I'm having difficulty deleting rows from a datagrid. I want to put a "delete" button on a form and achieve the same functionality as hitting the "delete" key on the keyboard for the selected row of a datagrid. I really want to do it generically so I have subclassed datagrid and made my own delete row method but I can only get it to work for datasources that are datatables or dataviews. Specifically when the datasource is a DataSet I...
5
14741
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am trying to delete these lines from the dataview like this: for (int i=0; i < dataView.Count; i++) if (dataGrid.IsSelected(i)) dataView.Delete(i);
2
1719
by: NDady via DotNetMonster.com | last post by:
Hi, I have a datagrid populated from a dataset. On every row in the grid I have a delete button. When the user presses on the delete button I remove the row from the dataset and rebind the datagrid. The problem is that after a couple of delete the index in the dataset does not match the index in the grid and the wrong record i deleted from the dataset. How can I solve this Problem? I am using the following procedure: Private Sub...
0
2013
by: Patrick.O.Ige | last post by:
I have a datagrid with checkboxes.. When a user clicks one check box and clicks the delete button it deletes that ROw. There another situation when a user clicks multiple rows so i had to loop throug the rows like so:- foreach (DataGridItem i in DataGrid1.Items) { CheckBox deleteChkBxItem = (CheckBox) i.FindControl ("DeleteRow"); if (deleteChkBxItem.Checked) {
4
4651
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following. I'm trying to delete all the rows in a dataview. There are 200 rows. Everything works fine until I delete half way through and then I'm told in an exception that "There is no row at position 100"
2
384
by: Job Lot | last post by:
My DataGrid is bound to DataView as follow DataGrid1.DataSource = myDS.Tables("Client_Consultant").DefaultView User can either delete all the rows in the DataGrid on by pressing "Delete All" button or provide Client_Consulatnt_ID and press "Delete" button to delete rows with that Client_Consulatnt_ID. My question is: 1. How can i delete all the rows on click of a button. 2. How can i remove all the rows with particular...
10
2346
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option. If the user right clicks on a column heading can I highlight that column and then delete it? I'm not exactly sure how to highlight it or figure out what column has been clicked. In my testing so far when I use the context menu I always get the...
3
1747
by: marshallarts | last post by:
Hello, I have a datagrid (grdShots) on a form, and a button to allow the user to delete records from the dataset underlying the grid. My code appears to work, because the row disappears from the datagrid. But the delete is not being updated back to the data source, because if I exit the app then start it again, the record reappears in the grid - it has not been deleted. Code for deleting the row is as follows. Column 0 in the grid...
9
1739
by: Hamed | last post by:
Hello I have a DataGrid that a is bound to a DataTable. Some of the rows in the DataTable should not be deleted. How can I prohibit deleting of some identified rows? The problem could be specified in the following format too: There is a DataView object that I want to prohibit deleting of some of its DataRowView objects. that is: when drv.Delete() is called (drv is the
0
9423
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
10219
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
10049
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
9865
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
8876
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
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.