Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am fetching records from the database. I want that a particular record always comes as the last element. How can I do this?

For eg: From database: A B C D

But, I want "B" to come always in last. I want this: A C D B
Posted

Found the answer at:

Link to answer
 
Share this answer
 
v2
Hi,
Please check this with example.

create table #tbl(Name varchar(10))
Insert into #tbl values('A')
Insert into #tbl values('B')
Insert into #tbl values('C')
Insert into #tbl values('D')

SELECT Name
FROM   #tbl
ORDER BY  CASE WHEN  Name='B' THEN 1 ELSE 0 END
Drop table #tbl
 
Share this answer
 
Hi,
Bind all the items to DropDownList except you need to see it at last and then at the end you can add that Item.

Suppose : A,B,C,D and you need C
So add a,c,and D then
Ddl.items.Insert(ddlites.items.count,C);

Thanks
www.alacraft.com.au
 
Share this answer
 

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