Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting item
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Deleting item
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01401166
Message ID:
01401166
Views:
141
Hi everybody,

Do you see what is wrong here?
 /// <summary>
        /// Delete Order Item
        /// </summary>
        /// <param name="grd"></param>
        /// <param name="dt"></param>
        /// <param name="rowNumber"></param>    
        private void DeleteOrderItem(DataGrid grd, OrderDetailsDS.OrderDetailsDataTable dt, int rowNumber) 

            {                 
                if (rowNumber >= 0)
                {
                DialogResult dr = MessageBox.Show("Are you sure to delete this item?", "Delete item", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        //delete items
                        _itemBiz.DeleteOrderItem(((OrderDetailsDS.OrderDetailsRow)dt.Rows[rowNumber]).ID);
                        //delete from the data table
                        dt.Rows[rowNumber].Delete();
                        this.UpdateTotals(dt); 
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
The item is deleted from the actual table, but then I'm getting an error on dt.Rows[rowNumber].Delete(); - the item can not be accessed. If I comment this line out, the item gets deleted, but the grid is not refreshed (and totals too).

I'm in a catch-22 with this problem now.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform