datagridview 数据处理方法 修改 删除 添加 下拉类表 弹出窗口
DataSet ds = dataoperate.getDs(strSql, "user_tb1");
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Columns[0].ReadOnly = true; //列不可编写
//显示当前的页数
if (pagenumber !=1)
pagenumber = pagenumber -1;
else
pagenumber =1;
label2.Text = pagenumber.ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
pagesize = int.Parse(textBox1.Text);
}
private void button5_Click(object sender, EventArgs e) //取消按钮,其实就是从新读本页数据库,在显示一次
{
DataOperate dataoperate = new DataOperate();
int pageindex = 0; //已经显示的条目数
string strSql;
if ((pagenumber - 1) > 0)
{
pageindex = (pagenumber - 1) * pagesize;////已经显示的条目数
strSql = "SELECT TOP " + pagesize.ToString() + " * FROM user_tb1 WHERE id>(select max(id) from (select top " + pageindex.ToString() + " id from user_tb1 order by id))";
}
else strSql = "select top " + pagesize.ToString() + " * from user_tb1 ";
//MessageBox.Show(strSql);//调试使用