• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 717
  • Last Modified:

ASP.net skip the first three records of an SqlDataSource

Hi,

I have a form with a DataList bound to an SQLDataSource.

The first three records returned are showed in a different manner, so I want the DataList to show records 4 onwards.

How can I do this?

Thanks,

Richard
0
rpm
Asked:
rpm
1 Solution
 
CodeCruiserCommented:
I think you will need to add some logic to your sql query to achieve that. Other option is to bind the list to a datatable which you can manipulate (delete first 3 rows).
0
 
TI2HeavenCommented:
The first three records returned are showed in a different manner
Could you please, give more detail?
0
 
rpmAuthor Commented:
They are being shown separatly, so they should not appear in the DataList at all
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
Jesus RodriguezIT ManagerCommented:
You can also unbind the datalist and populate manually. After execute the statement(query) to populate a datatable you can set the datasource for the datalist as the datatable that you get with the first 3 rows deleted
0
 
TI2HeavenCommented:
Can you change the select statement?
You can add conditions in the where clause to make sql not to give those 3 records.
Try to send us some code and screenshots as files attached because is hard to guess what you want…
0
 
Alan WarrenCommented:
Hi rpm,

would help if we could take a peek at your SQL Stored Procedure, but basically you can wrap the current SQL you use to return records, adding in a rownumber field, then filter where rownumber > 3; something like this:
CREATE PROCEDURE [dbo].[The_StoredProcedure]

AS
BEGIN
	
;

	WITH AllTheRecords AS
		(
		SELECT top (100) percent
		ROW_NUMBER() OVER(ORDER BY ID) as RowNum 
		,* -- The fields your sproc currently returns
		


		FROM tblThe_Table 
			
		)


	SELECT	*
	FROM AllTheRecords 
	WHERE (RowNum > 3) 

END



------------------------------------------
-- Testing expected results
------------------------------------------
-- exec [The_StoredProcedure] 

------------------------------------------

Open in new window

Alan ";0)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now