Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting item
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Deleting item
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01401166
Message ID:
01401166
Vues:
140
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform