请教下,DataGrid数据为什么不显示了
帮人修改毕业论文,已经不做程序员了,忘记差不多了。呵呵,哪位帮忙看看
datagrid不显示数据,但是写入数据库正常
if ( !IsPostBack )
{
string sql = "select x.*,(select CName from Course as y where y.CId = x.CPreCId) as CPreCName from Course as x where x.TId like '"+Session["Id"].ToString()+"'";
DataSet ds = Db.ExecuteSelectSql(sql);
test.Text = sql;
if ( ds != null && ds.Tables.Count > 0 )
{
if ( ds.Tables[0].Rows.Count > 0 )
{
lbCount.Text = "您一共开设有 "+ds.Tables[0].Rows.Count.ToString()+" 门课程!";
dgCourse.DataSource = ds.Tables[0];
dgCourse.DataBind();
for ( int i = 0; i < ds.Tables[0].Rows.Count; i++ )
{
if ( dgCourse.Items[i].Cells[3].Text == "必修" )
dgCourse.Items[i].Cells[8].Text = "必修";
else
{
sql = "select count(*) from SC where CId = "+ds.Tables[0].Rows[i]["CId"].ToString();
DataSet ds1 = Db.ExecuteSelectSql(sql);
if ( ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0 )
dgCourse.Items[i].Cells[8].Text = ds1.Tables[0].Rows[0][0].ToString();
}
}
}
else
{
lbCount.Text = "您暂时还没有开设课程!";
}
}
}
}