Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am using Visual Studio 2010 windows form and SQL Server 2008. I want select 10 rows on the gridview. If i click next button the next 10 rows have to show.

My codes are:
C#
public void loading1()
        {
            cn.Open();
            da1 = new SqlDataAdapter("SELECT TOP 10 * FROM Phone_Number;", cn);
            ds1 = new DataSet();
            da1.Fill(ds1);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                //comboBox1.Items.Clear();
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    dataGridView1.DataSource = ds1.Tables[0];
                }
            }
            cn.Close();

        }

But i don't know how to select next 10 rows.. Help me..
Posted
Updated 11-Sep-13 1:19am
v2
Comments
ZurdoDev 11-Sep-13 7:19am    
One way is to use the ROW_NUMBER() feature in SQL. Or use a control that supports paging already.
Vijaydhas 11-Sep-13 14:58pm    
I can not paging in windows form. In ASP .net there is option paging. But how to use that in Windows Forms??

See previous solution to the same requirement:
select second 100 rows in sql server - Solution 3[^]
select second 100 rows in sql server - Solution 1[^]

Good luck,
Edo
 
Share this answer
 
v2
u select all data from data base order by acc/dec

on 1st click u load only 10 records

on second click u clear the drid view
and load next 10 records

sorry if i am wrong
 
Share this answer
 
Comments
Vijaydhas 11-Sep-13 8:34am    
Yes.. I want do like that only. How to do that??

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