Click here to Skip to main content
15,886,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I get data of the first column of the last row in a grid view without using loop. Can anyone help me!!!
Posted
Updated 2-Jun-13 18:49pm
v2
Comments
Please mark my answer as solution as it has been solved in other thread.

Thanks,
Tadit

Use
C#
ItemContainerGenerator 
to get the Visual of your data.

C#
DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator                                     .ContainerFromItem(this.dataGrid.ItemsSource.OfType<data>().Last());</data>


Once you got the Row, cast the
C#
row.Item
to the binded object (In this case it is "Data") and get the desired value.

Hope it helps.

Kannan. S
 
Share this answer
 
Comments
Sumon562 3-Jun-13 1:03am    
It arises error like DataGridRow could not be found
Kannan Subramaniam 3-Jun-13 1:23am    
which DataGrid you are using WPF or some other??? the above code will work with WPF DataGrid.
Sumon562 3-Jun-13 1:35am    
A use normal gridview of asp .net c#
I have already answered you here - C Sharp Grid view data retrieve[^].
 
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