Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datatable with some values when i bind that datatable to grid view how can i bind a particular item at the top of the gridview.
Posted

1 solution

Hi Udayams.
You didn't gave any details of your code or Database. Just put your code or Database details so that i can try to solve out your problem.

As i understood, here i am writing some logic of your problem
Other than this here i am sending you a little example.You should refine your datatable query like that

Example:
C#
create table #t(sn int null,name varchar(10) null,code varchar(10) not null)
insert into #t values (1,'a','100')
insert into #t values (2,'b','200')
insert into #t values (3,'c','300')
insert into #t values (4,'d','400')
insert into #t values (5,'e','500')
--select * from #t

--now you want that "the row with name c come first without using order by clause or giving any where condition"
C#
select * from #t where code='300'
union all
select * from #t where code not in('300')


OUTPUT:
VB
3   c   300 (this is your particular row which you want on grid in first row)
1   a   100
2   b   200
4   d   400
5   e   500
 
Share this answer
 
v4

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