BatchUpdate in webgrid Issue when using SQL DataSource

3 replies. Last post: August 21, 2014 11:41 PM by Hans Kristian
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Hachi KMember

Hi,

I am having a webgrid with SQL Datasource which allows BatchUpdate. I've written code behind using the samples given with the product.

Now, my issue is this: When a single row is updated, it affects the Physical DB and is reflected when refreshed, properly. But, when a set of rows are affected, in the code behind, the values are sent to the SQL Update Parameters correctly but the Physical DB is updated to have the last row change being applied to all those corresponding rows.

For eg., I am changing 2 rows' with column "ratio" = 76 and 85 respectively and update it. The code behind passes the value properly and the grid is showing the same. Once I press refresh, the DB shows BOTH those two rows to have "ratio" = 85.

My SQL update command is as usual normal: "Update table_name set ratio=@Ratio where ID=@Id";

SQL Update Parameters: @Ratio, @Id

SQL Update Parameter Values: ["Ratio"].DefaultValue = newValue;

                                                ["Id"].DefaultValue = newValue; in switch according to column name;

This all, I have given in OnBatchUpdate function and foreach PendingChanges; SQLDS.Update() is called for time. Is there anything wrong with this code? If it is taking the latest Default value, then the Key field should also be pointing to the latest row alone, meaning only one row is affected, right?

Sample:

Id Ratio Override

1 90          true

2 100          true

After Update, my Physical DB is like this:

1 100 true

2 100 true


foreach row

"Id".defaultvalue = keyValue;

foreach column_changed_data

tmp_ratio = newvalue if column = "Ratio"

tmp_override = newValue if column = "Override"

end loop;

if override = "true"

"Ratio".Defaultvalue = tmp_ratio

"Override".DefaultValue = tmp_override

else

"Override".DefaultValue = tmp_override

SQL.update();

endloop;

I really appreciate the help. Thanks!

All times are GMT -5. The time now is 8:26 AM.
Previous Next