We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Deleting rows in GridDataboundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

4295 May 7,2003 01:59 AM UTC Oct 21,2003 01:50 PM UTC Windows Forms 5
loading
Tags: GridControl
Loga
Asked On May 7, 2003 01:59 AM UTC

These are 2 different methods i tried for deleting rows in a grid manually(say by right clicking the grid) 1) dgExpCharges.Binder.RemoveRecords(dgExpCharges.CurrentCell.RowIndex - 1, dgExpCharges.CurrentCell.RowIndex - 1) By using this I get a message saying that "There is no row at position 1" 2) table = dsChargeItemDefn.ExplodingChargeDetails If table.DefaultView.Count > (dgExpCharges.CurrentCell.RowIndex - 1) Then 'table.DefaultView.Item(dgExpCharges.CurrentCell.RowIndex - 1).Delete() By using this it sometimes deletes the non selected row. Say if i want to delete 3rd row,it would delete 1st or 2nd in a random way. Why this is happening? And how to fix this?

Administrator [Syncfusion]
Replied On May 7, 2003 04:44 AM UTC

> > These are 2 different methods i tried for deleting rows in a grid manually(say by right clicking the grid) > > 1) > dgExpCharges.Binder.RemoveRecords(dgExpCharges.CurrentCell.RowIndex - 1, dgExpCharges.CurrentCell.RowIndex - 1) > > By using this I get a message saying that "There is no row at position 1" > > 2) > > table = dsChargeItemDefn.ExplodingChargeDetails > If table.DefaultView.Count > (dgExpCharges.CurrentCell.RowIndex - 1) Then > 'table.DefaultView.Item(dgExpCharges.CurrentCell.RowIndex - 1).Delete() > > By using this it sometimes deletes the non selected row. > Say if i want to delete 3rd row,it would delete 1st or 2nd in a random way. > > > > Why this is happening? And how to fix this? Though it probably is not causing a problem here (as long as you only have 1 header row), you can use grid.Binder.RowIndexToPosition to get the zero-based position from the row index. Are you using a simple GridDataBoundGrid, or is it a "Expand"-type gierarchical grid? If it is an hierarchical grid, you will have to work directly with the child lists to remove items. If it is a simple GridDataBoundGrid then I would think your first code should work. It does for me in a simple grid. Do you have some setting, like maybe teh grid is disabled or ReadOnly or something else that might be preventing the deletion? Attached is a sample that seems to work as expected. It deletes the current row from both a button and a contextmenu item.

Loga
Replied On May 7, 2003 10:07 AM UTC

yes..Based on certain conditions i'm setting certain rows as readonly. Deletion of those readonly rows also gives problem sometimes. > > > > These are 2 different methods i tried for deleting rows in a grid manually(say by right clicking the grid) > > > > 1) > > dgExpCharges.Binder.RemoveRecords(dgExpCharges.CurrentCell.RowIndex - 1, dgExpCharges.CurrentCell.RowIndex - 1) > > > > By using this I get a message saying that "There is no row at position 1" > > > > 2) > > > > table = dsChargeItemDefn.ExplodingChargeDetails > > If table.DefaultView.Count > (dgExpCharges.CurrentCell.RowIndex - 1) Then > > 'table.DefaultView.Item(dgExpCharges.CurrentCell.RowIndex - 1).Delete() > > > > By using this it sometimes deletes the non selected row. > > Say if i want to delete 3rd row,it would delete 1st or 2nd in a random way. > > > > > > > > Why this is happening? And how to fix this? > > Though it probably is not causing a problem here (as long as you only have 1 header row), you can use grid.Binder.RowIndexToPosition to get the zero-based position from the row index. > > Are you using a simple GridDataBoundGrid, or is it a "Expand"-type gierarchical grid? If it is an hierarchical grid, you will have to work directly with the child lists to remove items. > > If it is a simple GridDataBoundGrid then I would think your first code should work. It does for me in a simple grid. Do you have some setting, like maybe teh grid is disabled or ReadOnly or something else that might be preventing the deletion? > > Attached is a sample that seems to work as expected. It deletes the current row from both a button and a contextmenu item.

Administrator [Syncfusion]
Replied On May 7, 2003 01:02 PM UTC

Is there any way you can exclude rows that you delete from having this readonly setting? You might try setting grid.Model.DiscardReadonly = true before you call your delete code, and resetting it to false afterwards.

Administrator [Syncfusion]
Replied On October 21, 2003 12:24 PM UTC

I noticed you said you are setting certain rows as readonly. I've been looking around how to do it and can't find any info. I'm new to Syncfusion, could you give me a hint how to set a row to readonly? Thanks in advance. Max > yes..Based on certain conditions i'm setting certain rows as readonly. > Deletion of those readonly rows also gives problem sometimes. > > > > > > > > These are 2 different methods i tried for deleting rows in a grid manually(say by right clicking the grid) > > > > > > 1) > > > dgExpCharges.Binder.RemoveRecords(dgExpCharges.CurrentCell.RowIndex - 1, dgExpCharges.CurrentCell.RowIndex - 1) > > > > > > By using this I get a message saying that "There is no row at position 1" > > > > > > 2) > > > > > > table = dsChargeItemDefn.ExplodingChargeDetails > > > If table.DefaultView.Count > (dgExpCharges.CurrentCell.RowIndex - 1) Then > > > 'table.DefaultView.Item(dgExpCharges.CurrentCell.RowIndex - 1).Delete() > > > > > > By using this it sometimes deletes the non selected row. > > > Say if i want to delete 3rd row,it would delete 1st or 2nd in a random way. > > > > > > > > > > > > Why this is happening? And how to fix this? > > > > Though it probably is not causing a problem here (as long as you only have 1 header row), you can use grid.Binder.RowIndexToPosition to get the zero-based position from the row index. > > > > Are you using a simple GridDataBoundGrid, or is it a "Expand"-type gierarchical grid? If it is an hierarchical grid, you will have to work directly with the child lists to remove items. > > > > If it is a simple GridDataBoundGrid then I would think your first code should work. It does for me in a simple grid. Do you have some setting, like maybe teh grid is disabled or ReadOnly or something else that might be preventing the deletion? > > > > Attached is a sample that seems to work as expected. It deletes the current row from both a button and a contextmenu item. >

Administrator [Syncfusion]
Replied On October 21, 2003 01:50 PM UTC

In a GridControl, you can use the GridControl.RowStyles[row].ReadOnly property to set an entire row to readonly. In a GridDataBoundGrid, you cannot directly do this for row or cell styles, only columns styles through the GridBooundColumn object for the column. Instead if you have to use PrepareViewStyleInfo to set these row or cell properties as in this KB article http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q561q which discusses BackColor, but it also applies to other GridStyleInfo properties like ReadOnly.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;