高手请进,关于DataGrid1_ItemDataBound的问题
我的数据库绑定:
public void DataGridBind()
{
SqlConnection myconn = new SqlConnection(SqlHelper.myconntionstring);
string sql = "Select * from DB_qiye_guestbook order by addtime desc ";
myconn.Open();
SqlDataAdapter dr = new SqlDataAdapter(sql, myconn);
DataTable guestbook=new DataTable ();
dr.Fill(guestbook);
myconn.Close();
DataGrid1.DataSource = guestbook;
DataBind();
}
在我的:
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
if(????== " ")
{
e.Item.Cells[4].Text = "sadasdas ";
}
else
{
e.Item.Cells[4].Text = "1111111 ";
}
}
}
问题:我想在绑定 reply 列进行操作,
如果数据库里面 reply列有数据则显示 1111111
如果没有数据则是显示 sadasdas
那我的 ???处该怎么写?谢谢回答
------解决方案--------------------if(e.Item.Cells[4].Text == " ") //这就是没数据啊
{
e.Item.Cells[4].Text = "sadasdas ";
}
else
{
e.Item.Cells[4].Text = "1111111 ";
}