如何从对象创建条件并添加到datagridview?
这是我的代码..
dataGridView1.Rows.Clear();
Connection.sqlConnection.Close();
Connection.Connector(server, database, user, password);
Connection.sqlCommand.Connection = Connection.sqlConnection;
Connection.sqlCommand.CommandType = CommandType.Text;
Connection.sqlCommand.CommandText = "SELECT ID,KOSAT,KETERANGAN,DELETEFLAG FROM KOSAT";
SqlDataReader kosatList = Connection.sqlCommand.ExecuteReader();
while (kosatList.Read())
{
// this....................
dataGridView1.Rows.Add(kosatList["ID"], kosatList["KOSAT"], kosatList["KETERANGAN"], kosatList["DELETEFLAG"]);
// until this................
}
Console.WriteLine("aaa = "+list);
Connection.sqlConnection.Close();
dataGridView1.ClearSelection();
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
根据我的代码......我想从kosatList["DELETEFLAG"]
这样创建一个条件..
string yesORno;
if(kosatList["DELETEFLAG"].Equals("Y"))
{
yesORno = "YES";
}
else if(kosatList["DELETEFLAG"].Equals("N"))
{
yesORno = "NO";
}
那么如何将yesORno
添加到行datagridview1?
我试过这个..
dataGridView1.Rows.Add(kosatList["ID"], kosatList["KOSAT"], kosatList["KETERANGAN"], yesORno);
但我收到了错误,因为Rows.Add()
==>必须是Object
答案 0 :(得分:1)
我只是更改查询以引入您想要的数据,因此您不必操纵它:
if current_user.ranking_index > tournament.max_ranking_index || current_user.ranking_index < tournament.min_ranking_index
flash[:alert] = "Vous n'avez pas le classement requis pour vous inscrire dans ce tournoi"
end