Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
I want to display row i gridview which is last added in database.
Posted
Updated 16-Jul-13 1:40am
v2
Comments
Nirav Prabtani 16-Jul-13 7:18am    
please be more specific..:)
vipan.net 1-Feb-16 4:16am    
are you looking for last record only in grid or last record first in gridview record list ?

If it is a Winform, to scroll to bottom of DataGridView,
C#
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount-1;
 
Share this answer
 
v2
Comments
firaso 16-Jul-13 7:33am    
I don't show last row in datagridview but I want to fetch from database and show it in datagridview
Naz_Firdouse 16-Jul-13 7:38am    
are you able to bind the data to datagridview?
what is your exact issue? Issue in binding or issue in displaying the last record???
try this query in sql...

SQL
select * from TableName where id in (select max(id) from TableName) 
 
Share this answer
 
If you want to get last one record from your db and show in your grid, you can use the Top 1
"select top 1 * from tb_man order by datefield desc"
 
Share this answer
 
<code><code><>&<a href=""></a><a href=""></a>[<a href="" target="_blank">^</a>]</code></code>
 
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