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(); } }
this.Data should be your source data object. In this case it would be a microsoft DataSet object. If you're binding your grid to a different sort of object, that code might need to be a little different.