Saving the formula values

hi,

iam binding data from dataset to sheet.

iam using formulas here. when i click on submit button its displaying all formula values. but when i click on save button its saving only the values came from databse. its not saving the values generated by formulas

ima sending one attachament with this . check it out once and please rectify my problem

swapna

Hi,

Thanks for your project, we will get back to you soon.

Thank you.

hi

my project is going to complete , if you give the solution as possible as early we can purchase the grid.

we have to show the project on monday to client so please give me the solution as possible as early. we are using ajax in this applicaion.

thanks

swapna

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.

hi,

its working fine when we add new rows. but the main problem is after deleting a row from the grid i click on save button. its giving error at the place

DataRowView rowView = (DataRowView)sheet.GetRowBindObject(row);

rowView["heading"] = sheet.Cells[row, 3].Value;

what is the problem. can you give me the solution for this.

swapna

Hi,

Can you get the error message about the error?