DataGridView, BindingSource and RowCount

DataGridView, BindingSource and RowCount

Old forum URL: forums.lhotka.net/forums/t/5376.aspx


Sinudeity posted on Wednesday, September 10, 2008

Good morning folks

I have setup a CSLA Windows form, running a DataGridView.
The DataSource is attached to a BindingSource.

Ive been working on paging, that skips 10 records at a time,
instead of just skipping to the next record.

My problem is, I need to somehow limit the DataGridView
to only show 10 records at a time. DataGridView.RowCount
gives me an error, as it is bound.

What is the best way to achieve a limited record count
on the Grid?

Kind regards

AndyW replied on Wednesday, September 10, 2008

 

I did something similar, but I limited the records coming back in the Stored Procedure.  That was the approach I used, I thought it would be better to return only the records I was interested in.

A sample query.

SELECT
    ResultSet.row_number,
    ResultSet.AddressID,
    ResultSet.CompanyName
FROM
    (
      SELECT
        ROW_NUMBER() OVER ( ORDER BY Address.CompanyName ) AS row_number,
        Address.AddressID,
        Address.CompanyName
      FROM
        dbo.Address
    ) AS ResultSet
WHERE
    ResultSet.row_number BETWEEN 1 AND 10

Cheers

Andy

Sinudeity replied on Wednesday, September 10, 2008

Hi Andy

Thanks a stack for your response.
I should have mentioned that Im using LLBLGen
for my DataAccess Layer. Leaving me with
limited control to do what you suggest.

Im going to investigate, but I dont think I can impliment it like that.

Copyright (c) Marimer LLC