Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how to get data of last row of data grid control

please help
Posted

Try:
C#
if (myDataGridView.Rows.Count > 0)
    {
    DataGridViewRow row = myDataGridView.Rows[myDataGridView.Rows.Count - 1];
    ...
    }



"i am using data grid control not data grid view control..."


Then you need to use the CurrencyManager:
C#
CurrencyManager cm = (CurrencyManager)this.BindingContext(myDataGrid.DataSource, myDataGrid.DataMember);
DataView dv = (DataView)cm.List;
DataRow dr = dv[cm.Position].Row;
 
Share this answer
 
v2
Comments
yogesh89 4-Oct-11 3:48am    
i am using data grid control not data grid view control...
OriginalGriff 4-Oct-11 4:34am    
Answer updated
try the follwoing where DataGridView1 is name of your datagrid
C#
DataGridViewRow dr = DataGridView1.Rows[DataGridView1.Rows.Count - 1];
 
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