Deleting rows from DataGrid

G

Guest

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
 
W

William Ryan eMVP

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/community/newsgroups
Job Lot said:
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:
 
W

William Ryan eMVP

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/community/newsgroups
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top