最简单的用 datagrid 每次显示一条记录

解决方案 »

  1.   

    2. 用一个文本框记录你的当前记录的主键信息,用 sql 语句
    下一条:
     select * from tablename where  clumnname > '" & textbox1.text & "'" order by clumnname asc
    上一条
     select * from tablename where  clumnname < '" & textbox1.text & "'" order by clumnname desc注意关键技术:  > -------  asc
                    < -------  descgood luck !
      

  2.   

    哦,我不是说的很清楚了吗?
    sql="select * from tablename where  clumnname > '" & textbox1.text & "'" order by clumnname asc"
    上一条和下一条关键就是  > 和 < 和 order by  desc/asc
      

  3.   

    哦,呵呵呵,好吧,我在说一遍
    1 . datagrid 有分页功能吧,有上一页,下一页!
    2 . 如果你用的是 sql 数据库 在 查询分析器里用,关键是用 sql 语句实现
        我上面的sql 语句 
    例如: 你的表 tb_user
     userid    name
       1        sdf
       sdf       df
       df        df
       dfff      sdfuse sql 
    下一个 :
     select * from  tb_user  '用来显示所有数据
     select * from  tb_user where  userid > 'df' order by userid asc   '下一条
     select * from  tb_user where  userid < 'df' order by userid desc   '上一条
      

  4.   

    private void Last_Click(object sender, System.EventArgs e)
    {
    if (DS.Tables[0].Rows.Count>0)
    {
    CurrentRow--;
    if (CurrentRow<0)
    {
    CurrentRow=0;
    }
    Display_Record(CurrentRow);
    RecordNumber.Text="CurrentRow is " + (CurrentRow+1).ToString()+", Total is "+DS.Tables[0].Rows.Count.ToString();
    } }
    //Move record to next
    private void Next_Click(object sender, System.EventArgs e)
    {
    if (DS.Tables[0].Rows.Count>0)
    {
    CurrentRow++;
    if (CurrentRow>DS.Tables[0].Rows.Count -1)
    {
    CurrentRow=DS.Tables[0].Rows.Count -1;
    }
    Display_Record(CurrentRow);
    RecordNumber.Text="CurrentRow is " + (CurrentRow+1).ToString()+", Total is "+DS.Tables[0].Rows.Count.ToString();
    }
    }
    private void Display_Record(int CurrentRow)
    {
    DS.Tables[0].Clear();
    oleDbDataAdapter1.Fill(DS,"employee");
    DataView dv_employee = new DataView(DS.Tables[0],"employeeid='"+DS.Tables[0].Rows[CurrentRow][0].ToString()+"'","",DataViewRowState.CurrentRows);
    try
    {
    if (CurrentRow>=0 && CurrentRow<=DS.Tables[0].Rows.Count -1)
    {
    EmployeeID.Text=dv_employee.Table.Rows[CurrentRow][0].ToString();
    FirstName.Text=dv_employee.Table.Rows[CurrentRow][1].ToString();
    LastName.Text=dv_employee.Table.Rows[CurrentRow][2].ToString();
    Title.Text=dv_employee.Table.Rows[CurrentRow][3].ToString();
    Extension.Text=dv_employee.Table.Rows[CurrentRow][4].ToString();
    Mobilephone.Text=dv_employee.Table.Rows[CurrentRow][5].ToString();
    officelocation.Text=dv_employee.Table.Rows[CurrentRow][6].ToString();
    Birthday.Text=Convert.ToString(dv_employee.Table.Rows[CurrentRow][7].ToString());
    sittinglocation.Text=dv_employee.Table.Rows[CurrentRow][8].ToString(); if (dv_employee.Table.Rows[CurrentRow][9] != null && dv_employee.Table.Rows[CurrentRow][9] != DBNull.Value)
    {
    byte[] p_stream = (byte[])dv_employee.Table.Rows[CurrentRow][9];
    Stream st = new MemoryStream(p_stream);
    picture.Image=Image.FromStream(st);
    st.Close();
    }
    else
    {
    picture.Image=null;
    }
    picture.Refresh(); comboBox1.SelectedValue=dv_employee.Table.Rows[CurrentRow][10].ToString();

    RecordNumber.Text="CurrentRow is " + Convert.ToString(CurrentRow+1) + ", Total is "+DS.Tables[0].Rows.Count.ToString();
    }
    else
    {
    RecordNumber.Text="No Record!";
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }
    }
      

  5.   

    winform的,webform也差不多,除了图像,好像没有什么要改的。
      

  6.   

    no so difficulthttp://www.c-sharpcorner.com/Code/2003/July/NavigationSystemInASPNet.asp
      

  7.   

    各位大哥,能不能帮我到这儿再看一下,马上结贴。http://community.csdn.net/Expert/topic/3077/3077338.xml?temp=.2317011
      

  8.   

    能帮我到这儿看一下吗?
    http://community.csdn.net/Expert/topic/3077/3077338.xml?temp=.2317011
      

  9.   

    能帮我到这儿看一下吗?
    http://community.csdn.net/Expert/topic/3077/3077338.xml?temp=.2317011