Jin Yong
Jin Yong

Reputation: 43788

how can I pass null into asp:Parameter

I have the following code:

<asp:SqlDataSource ID="dsLeave" 
                   runat="server" 
                   ConnectionString="<%$ ConnectionStrings:test %>"
                   SelectCommand="app_leave_notification_select"
                   SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter Name="employee_id" Type="int32" />
    </SelectParameters>                
</asp:SqlDataSource>

Does anyone know how can I pass null into asp:Parameter employee_id?

Upvotes: 1

Views: 1588

Answers (2)

AndyC
AndyC

Reputation: 1335

Add a ConvertEmptyStringToNull="true" into the Parameter so it would like like:

<asp:Parameter Name="employee_id" 
               Type="int32" 
               ConvertEmptyStringToNull="true" /> 

Add pass in an empty string.

I got this from this blog entry: http://www.blog.sumantdubey.com/post/SQLDataSource-Passing-Null-Parameters.aspx

Upvotes: 3

Ranjeet
Ranjeet

Reputation: 19

<asp:Parameter Name="employee_id" 
               Type="Int32?" 
               ConvertEmptyStringToNull="true" />

Upvotes: 1

Related Questions