473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Deleting rows from DataGrid

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 Client_Consulatnt_ID

thanx

Jul 21 '05 #1
2 1490
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****@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
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 Client_Consulatnt_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****@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
how wud i find index for rows with specified Client_Consulatnt_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****@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
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 Client_Consulatnt_ID

thanx


Jul 21 '05 #3

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

Similar topics

1
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...
5
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...
2
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...
0
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...
4
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...
2
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"...
10
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....
3
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...
9
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.