Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
RejectChanges()
posted

I'm using webgrid samples provided to update cell and save datatset back to DB.

The sample uses the code below. The project does not recognise 'this.Data' & 'RejectChanges()'

I have added using Infragistics.WebUI.UltraWebGrid;

            DataRow row=null;
            DataTable table=null;
            object key=e.Cell.Row.DataKey;
           
            table=this.Data.Tables[e.Cell.Band.BaseTableName];

            //Try to find the row that needs to be updated.
            if (key!=null)
                row=table.Rows.Find(key);

            //Try to update the cell in this row.
            if(row!=null)
            {
                try
                {
                    object newVal=e.Cell.Value;
                    if(e.Cell.Column.Key=="UnitPrice")newVal=String.Copy(e.Cell.Text).Replace("$","");
                    row[e.Cell.Column.Key]=newVal;
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    this.Data.RejectChanges();
                }
            }