hoang
hoang

Reputation: 1917

How to set a Parameter DefaultValue to an empty string in ObjectDataSource methods?

In the example below, the DefaultValue of my Foo Parameter passes a null value instead of string.Empty

<asp:ObjectDataSource ID="MyDataSource" runat="server" SelectMethod="GetAll"
    UpdateMethod="MyUpdateMethod" TypeName="My.Namespace.MyProvider">
    <UpdateParameters>
        <asp:Parameter Name="Key" Type="Int16" />
        <asp:Parameter Name="Foo" Type="String" DefaultValue="" />
    </UpdateParameters>
</asp:ObjectDataSource>

Though I can handle that in MyUpdateMethod, is there a way to set the DefaultValue of a string parameter to an empty string ?

Upvotes: 1

Views: 3253

Answers (2)

Etch
Etch

Reputation: 3054

There is a property on the Parameter for ConvertEmptyStringToNull

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.parameter.convertemptystringtonull.aspx

Upvotes: 2

Adrian Iftode
Adrian Iftode

Reputation: 15673

<asp:Parameter Name="Foo" Type="String" ConvertEmptyStringToNull="false" />

Upvotes: 5

Related Questions