Thursday, 27 March 2014

Default value for SQLServerDatasource string parameter must contain a default value to be passed as empty string!

Scenario:
- FormView in edit mode with SQLServerDatasource update statement set to a stored procedure which contains a string, nvarchar(max), parameter.
- Within the aspx file, the default parameter value = ""
- Parameter is data binded to an empty TextBox.
- FormView is submitted for update.

Observation:
- Stored procedures string parameters when defaulted as empty strings, they are not passed to the stored procedure, rather than passed as empty strings.

Workaround# 1:
- Insert a space with the parameter default value in the aspx file such that:
default = " " rather than default = " ".

Workaround# 2:
- Handling the event SQLServerDataSource.Updating, so that to manually add a space within the parameter value when the TextBox.Text value is empty.


- Visual Studio 2013, version 12.0.30110.00 Update 1
- .NET Framework 4.0

Thursday, 20 March 2014