Last post Feb 24, 2011 04:30 AM by MS.NET10
Feb 16, 2011 04:58 PM|baseballrock17|LINK
I am currently trying to update all instances of a value (txtOldName.Text) in a SQL table with a new value (txtNewName.Text).
By using a publish button, how could I notify the user how many records will be updated and ask them if they are sure they want to proceed.
A high level step-by-step would be appreciated. I can figure out the bits and pieces if just given an outline of how this might be done.
Feb 16, 2011 05:56 PM|AZMatt|LINK
Feb 18, 2011 11:31 AM|WombatEd|LINK
I would use a SQL Select with a COUNT(*). select count(*) from yourTable where yourNameField = @oldNameValue Then you can capture the count, display the confirmation message, and finally do the update. Matt
And use either an output parameter or a returnvalue to get the count from SQL to your code-behind.
Feb 22, 2011 03:23 PM|baseballrock17|LINK
Could you speak to how I can dynamically apply the COUNT(*) value from my SELECT query to the "return confirm('');?
Feb 23, 2011 09:19 AM|baseballrock17|LINK
I ended up using the following code to create the popup when the txtOldName_TextChanged event fired off.
btnUpdateName.Attributes.Add("onclick", "return confirm('Do you want to update " & COUNT.ToString & " records?');")
Thus, when the OldName text box changes, the behavior of the Update button gets the new prompt text, based on the data within the OldName text box itself.
Thanks for all your help, guys!
Feb 24, 2011 04:30 AM|MS.NET10|LINK
Rather then writing code at Text_Changed event... which may irritate user for each key press.
Better on foucs out by calling Server Side method get count in JS and Popup the message.
this will avoid multiple round trips.