Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select a single record at a time from SQL Server. & want to select next/previous record on button's click event in C# OR ASP.net.


OR

I wanna use next & previous button for the photo gallery in ASP.net
Posted
Updated 15-Jun-10 22:44pm
v2

your query will be somewhat similar like this, just set the offset.

SQL
SELECT * FROM (
	SELECT TOP 1 * FROM (
		SELECT TOP [Y] LogID,EventID,Priority,Severity,Title
		FROM [LOG]
		WHERE Severity='Error'
		ORDER BY LogID  ASC) as InnerTable
	ORDER by LogID DESC) as OuterTable
ORDER by LogID ASC

-- Replace [Y] with the offset.
 
Share this answer
 
I don't understand what you are trying to do.
Let me know if I am getting you right?
I guess your query returns multiple rows. Now in your UI you need to display 1 record at a time and on button click you need to show the next record (in ASP.NET). If this is you requirement, you need to use a DetailsView[^].
You can loop through the next record using DetailsView Paging[^].

If this is not what you want, give an explanation of your requirement.
 
Share this answer
 
ok , if you are talking about reading records from the application end you can just use a select query and get the data to the application layer and navigate through it , but if you are trying to do it at the sql server then it will be bit difficult (but hope it is possible by passing an argument), and back to application layer once you read the data from the DB you can use either dataset or a collection to store it.this will allow you to navigate as you want , but if you use datareader it will allow you to navigate only forward and not backward...
 
Share this answer
 
<><a href=""></a><a href=""></a>[<a href="" target="_blank"></a>]
 
Share this answer
 
 
Share this answer
 
Comments
[no name] 1-Jul-12 16:09pm    
Do you really think that the OP has been waiting 2 years for this answer?
Milind Karpe 2-Jul-12 1:17am    
This solution is for new readers...
do custom paging, just google it for custom paging proc
 
Share this answer
 
Comments
[no name] 1-Jul-12 16:44pm    
Do you really think that the OP has been waiting 2 years for this answer?
Shemeer NS 1-Jul-12 16:47pm    
not really... it's for others who is looking for the same solution... this asked just before 2 weeks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900