473,396 Members | 1,860 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,396 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 1494
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
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,...

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.