Gridview not getting sp records

D

DavidC

We have an aspx page with a GridView tied to an SQL Server stored procedure.
When the GridView was setup we did a "test query" and all expected records
displayed. However, when we open the page we get no records. Below are the
parameters on the SqlDataSource control. The 2 dates are defaulted to NULL
in the stored proc so that only dates with NULL are displayed. I also ran
the stored proc from SQL server and it ran fine when I checked the send null
values for the dates. Any ideas where I should look? Thanks.

asp:QueryStringParameter Name="Branch" QueryStringField="brn" Type="Int16"
asp:ControlParameter ControlID="txtCheckDateStart" DbType="Date"
Name="CheckDateStart" PropertyName="Text"
asp:ControlParameter ControlID="txtCheckDateEnd" DbType="Date"
Name="CheckDateEnd" PropertyName="Text"
 
D

DavidC

DavidC said:
We have an aspx page with a GridView tied to an SQL Server stored procedure.
When the GridView was setup we did a "test query" and all expected records
displayed. However, when we open the page we get no records. Below are the
parameters on the SqlDataSource control. The 2 dates are defaulted to NULL
in the stored proc so that only dates with NULL are displayed. I also ran
the stored proc from SQL server and it ran fine when I checked the send null
values for the dates. Any ideas where I should look? Thanks.

asp:QueryStringParameter Name="Branch" QueryStringField="brn" Type="Int16"
asp:ControlParameter ControlID="txtCheckDateStart" DbType="Date"
Name="CheckDateStart" PropertyName="Text"
asp:ControlParameter ControlID="txtCheckDateEnd" DbType="Date"
Name="CheckDateEnd" PropertyName="Text"

I noticed one more thing that might help. When I removed the 2 date
parameters the GridView displayed fine when opening the page. So, how do I
get date fields to default to null as the stored proc only needs them if they
are entered? Thanks.

David
 
G

Guest

I noticed one more thing that might help.  When I removed the 2 date
parameters the GridView displayed fine when opening the page.  So, how do I
get date fields to default to null as the stored proc only needs them if they
are entered?  Thanks.

David

Hi David,

according to Microsoft: "by default the SqlDataSource does not perform
a Select operation if any of the associated parameters to the
SelectCommand are null. To allow the select operation to execute even
when a null parameter is passed, you can set the
CancelSelectOnNullParameter property to false."

That is, try to set CancelSelectOnNullParameter into false, because
the default value is true.

<asp:SqlDataSource runat="server"...
CancelSelectOnNullParameter="False">

http://msdn.microsoft.com/en-us/lib...qldatasource.cancelselectonnullparameter.aspx

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top