Click here to Skip to main content
14,733,542 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hello ALL,
When I click on button display it populates the datagrid with my data. No problem there.
private void btnDisplay_Click_1(object sender, EventArgs e)

        da.SelectCommand = new SqlCommand("SELECT FirstNum, SecondNum,  ThirdNum, FourthNum, FifthNum, Date FROM tblNUMBERS_1", cs);

        DataView dv = new DataView(ds.Tables[0], "Date = Date", "Date Desc", DataViewRowState.CurrentRows);
            dg.DataSource = dv;
            tblNUMBERSBS_1.DataSource = dv;
            dg.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

I'm able to navigate through the records in the table.

private void btnNext_Click(object sender, EventArgs e)

When I click on row lets say '#8' it does select the entire row as I want. When I click button 'Move Next' it does move it to record/row #2 instead of row #9.
What is the best approach to achieve that? to move it to row #9?

tblNUMBERSBS_1 is a binding source, yes..

BindingSource tblNUMBERSBS_1 = new BindingSource();
Updated 17-May-11 6:29am
BobJanova 17-May-11 11:21am
I'm not sure what tblNUMBERSBS_1 is, but it isn't directly linked to the data source, so it doesn't know you changed the selection. Is it a BindingSource? If so, try setting dg.DataSource to it not to the underlying view.

1 solution

It doesn't work because you set the DGV DataSource to the dv data and you set the bindingsource to the same thing. You have two seperate currency managers in play here when you should have only one.

Set the bindingsource to dv then set the DGV Datasource to the bindingsource.
JML_ 17-May-11 14:40pm
Thank you sir..

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