get dataset row count

S

Sam

Hi,
I've got a datagrid and a dataset used as the datasource.
I'd like to do a test, if the index of the selected row in the grid is
greater than the dataset.tables(0).rows.count. The problem is that if I
edit the last row of the grid, a new row will be added below and to the
dataset. Therefore the number of rows in the dataset won't be equal to
the number of records in the database. How can I get the number of rows
in the dataset originally ?

Thx
 
C

Cor Ligthert

Sam,

Strange.
The datagrid reflects the rows in your datasource.

There is one time that you can say it is not. And that is while the user is
editing because he/she by instance has added a new row. The data in a
datagrid is not updated in the datasource, as long as the cursor is on the
same datagrid row.

However for that is the instruction Endcurrentedit by instance like this.
\\\\
BindingContext(ds.Tables(0)).EndCurrentEdit()
////

I hope this helps,

Cor
 
A

Ahmed

So I cut and paste the code from my program. The correct one code
should be

Me.BindingContext(D­ataGrid1.DataSource).Count
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top