Hi,
The grid doesn't save the formula caculating result to the dataset automatically. You should implement this manually. Here is a sample:
Set formulas after DataBinding:
// Bind the sheet to the dataset.
GridWeb1.DataBind();
for (int row = 3; row <= sheet.Cells.MaxRow; row++)
{
// Sets formulas for the 7th column.
sheet.Cells[row, 6].Formula = "= A" + (row+1).ToString() + " * 1.4";
}
GridWeb1.WebWorksheets.RunAllFormulas();
Set values before updating the database:
// Updates the datarows with the caculated value.
WebWorksheet sheet = GridWeb1.WebWorksheets[0];
for (int row = 3; row <= sheet.Cells.MaxRow; row++)
{
DataRowView rowView = (DataRowView)sheet.GetRowBindObject(row);
rowView["UnitPrice"] = sheet.Cells[row, 6].Value;
}
GridWeb1.WebWorksheets.RunAllFormulas();
DemoDatabase db = new DemoDatabase();
string path = MapPath(".");
path = path.Substring(0, path.LastIndexOf("\\"));
path = path.Substring(0, path.LastIndexOf("\\"));
db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Database\\demos.mdb";
try
{
db.oleDbDataAdapter1.Update((DataSet)GridWeb1.WebWorksheets[0].DataSource);
}
finally
{
db.oleDbConnection1.Close();
}
Wish this helps.