• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • 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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
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 WarrenApplications DeveloperCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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