Solved skip the first three records of an SqlDataSource

Posted on 2012-08-28
Last Modified: 2012-08-28

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?


Question by:rpm
    LVL 83

    Expert Comment

    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).
    LVL 4

    Expert Comment

    The first three records returned are showed in a different manner
    Could you please, give more detail?
    LVL 1

    Author Comment

    They are being shown separatly, so they should not appear in the DataList at all
    LVL 13

    Expert Comment

    by:Jesus Rodriguez
    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
    LVL 4

    Expert Comment

    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…
    LVL 26

    Accepted Solution

    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]
    	WITH AllTheRecords AS
    		SELECT top (100) percent
    		,* -- The fields your sproc currently returns
    		FROM tblThe_Table 
    	SELECT	*
    	FROM AllTheRecords 
    	WHERE (RowNum > 3) 
    -- Testing expected results
    -- exec [The_StoredProcedure] 

    Open in new window

    Alan ";0)

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now