我使用的DATAGRID组件,列出数据库的一个表里的所有数据。LINE这个列有1到16之间的随机数值,例如:
id   line  text
1    6     aa
2    1     aa
3    3     aa
4    8     aa
5    1     aa
6    2     aa
7    3     aa我需要在DATAGRID组件里按line里的所有的“1”先显示,再显示所有的“2”…………一直到“16”。请问有什么方法可以实现!!!

解决方案 »

  1.   

    DATAGRID.Sort ="line  desc "
    大概这个意思
      

  2.   

    我的代码是这个:
    SqlConnection con = DB.createCon();
    con.Open();
    SqlCommand cmd = new SqlCommand("select * from data_one where nday = '"+linelist.t1+"' ",con);
    SqlDataAdapter sda = new SqlDataAdapter("select * from data_one where nday = '"+linelist.t1+"'",con);
    DataSet ds = new DataSet();
    sda.Fill(ds);
    this.DataGrid1.DataSource = ds;
    this.DataGrid1.DataBind();
    con.Close();怎么改???这个代码是在LOAD里面的。
      

  3.   

    DataView dv = (DataView)ds.Tables["Score"].DefaultView; 
     dv.Sort = (string)ViewState["SortField"] + " DESC"; score.DataSource = dv;
     score.DataBind();
      

  4.   

    楼主在Sql里通过order by 排序不行么?SqlDataAdapter sda = new SqlDataAdapter("select * from data_one where nday = '"+linelist.t1+"' Order By Line",con);