2011-09-13 78 views
0
private void BindGridView(string field) 
    {  
     string userName = field; 
     //Get OrganisationID from user Table 
     string OrgIdQueryText = "SELECT tbl_organisation_OrganisationID FROM tbl_user WHERE Email "; 
     int newOrgID = Convert.ToInt32(server.performQuery(OrgIdQueryText, userName, MySqlDbType.VarChar)); 

     MySqlCommand command = new MySqlCommand(); 
     DataSet ds = new DataSet(); 

     string MysqlStatement = "SELECT MsgID, MsgText, Title, RespondBy, ExpiresBy, OwnerName, Status FROM tbl_message WHERE tbl_user_tbl_organisation_OrganisationID = @Value1"; 
     using (server) 
     { 
      MySqlParameter[] param = new MySqlParameter[1]; 
      param[0] = new MySqlParameter("@value1", MySqlDbType.Int32); 
      param[0].Value = newOrgID; 
      command.Parameters.AddWithValue("@Value1", newOrgID); 
      ds = server.ExecuteQuery(CommandType.Text, MysqlStatement, param); 
     } 

     Grid_Messagetable.DataSource=ds; 
     Grid_Messagetable.DataBind(); 
} 

我数据绑定网格视图和它显示基于所述的MsgID的行。我想,这样的新的消息被显示在网格排序网格视图中asp.net

+0

您正在使用的

回答

4
顶部

更改您的查询做适当的像这样的排序是降序排列显示:

string MysqlStatement = "SELECT MsgID, MsgText, Title, RespondBy, ExpiresBy, OwnerName, Status FROM tbl_message WHERE tbl_user_tbl_organisation_OrganisationID = @Value1 order by MsgID desc";