ASP.Net Grid with SqlDatasource using Stored Procedure is Blank

9. August 2011 10:25

After a lot of searching, I finally found the answer here. It seems that when you are using an SqlDataSource that when a parameter is null, it will cancel a select by default. You need to add the attribute of CancelSelectOnNullParameter="false". It was very frustrating, as using the SQL Server Profiler, the query wasn't even being issued, and it was a pain to track down.

I'm putting this up here, to hopefully help others with a similar situation in the future.

Tags:

Paged Results in T-SQL

23. February 2010 19:08

Okay, so I wanted to return a paged result set from a Stored Procedure in Microsoft SQL Server in T-SQL. The results in question can be easily fed via a web service endpoint to a Silverlight, DHTML or other dynamic grid. My own use is to populate a jqGrid.

The features I need are to be able to return only the relevant results for the current page, as well as a count of the total rows available. I need to be able to input the current page number, an arbitrary page size, as well as dynamically sort on a given column. My real world use is a fairly complex set of joined tables, with several input parameters, so I am going to limit me queries to one table with the following format:

CREATE TABLE MyList (
    [id] UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
    [created] DATETIME NOT NULL DEFAULT GETDATE(),
    [name] NVARCHAR(100) UNIQUE NOT NULL DEFAULT '',
    [description] NVARCHAR(250) UNIQUE NOT NULL DEFAULT ''
);

More...

Tracker1

Michael J. Ryan aka Tracker1

My name is Michael J. Ryan and I've been developing web based applications since the mid 90's.

I am an advanced Web UX developer with a near expert knowledge of JavaScript.