﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - sqldatasource</title><link>http://www.intersoftsolutions.com/Community/Tags/sqldatasource/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>BatchUpdate in webgrid Issue when using SQL DataSource</title><link>http://www.intersoftsolutions.com/Community/Tags/sqldatasource/</link><pubDate>Tue, 19 Aug 2014 09:51:06 GMT</pubDate><dc:creator>sample4170</dc:creator><category>WebGrid</category><category>BatchUpdate</category><category>sqldatasource</category><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I am having a webgrid with SQL Datasource which allows BatchUpdate. I've written code behind using the samples given with the product.&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;My SQL update command is as usual normal: "Update table_name set ratio=@Ratio where ID=@Id";&lt;/p&gt;&lt;p&gt;SQL Update Parameters: @Ratio, @Id&lt;/p&gt;&lt;p&gt;SQL Update Parameter Values: ["Ratio"].DefaultValue = newValue;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ["Id"].DefaultValue = newValue; in switch according to column name;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;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?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;Sample:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Id&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;Ratio&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;Override&lt;/p&gt;&lt;p&gt;1&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;90&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;true&lt;/p&gt;&lt;p&gt;2&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;100&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;true&lt;/p&gt;&lt;p&gt;After Update, my Physical DB is like this:&lt;/p&gt;&lt;p&gt;1&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;100&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;true&lt;/p&gt;&lt;p&gt;2&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;100&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;true&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;foreach row&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;"Id".defaultvalue = keyValue;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;foreach column_changed_data&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;			&lt;/span&gt;tmp_ratio = newvalue if column = "Ratio"&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;			&lt;/span&gt;tmp_override = newValue if column = "Override"&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;end loop;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;if override = "true"&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;"Ratio".Defaultvalue = tmp_ratio&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;"Override".DefaultValue = tmp_override&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;else&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;"Override".DefaultValue = tmp_override&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;SQL.update();&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;endloop;&lt;/p&gt;&lt;p&gt;I really appreciate the help. Thanks!&lt;/p&gt;</description></item></channel></rss>