大家帮我看看这个是哪里的问题
string sql = "select SurveyID,SurveyDate,SurveyProject,SurveyCPI,SurveyLength,SurveyMemo,SurveyStatus from survey";
con = new SqlConnection(connstr);
con.Open();
SqlCommand com = new SqlCommand(sql, con);
SqlDataReader read = com.ExecuteReader();
while (read.Read())
{
SurveyID = read["SurveyID"].ToString();
SurveyDate = read["SurveyDate"].ToString();
SurveyProject = read["SurveyProject"].ToString();
SurveyCPI = read["SurveyCPI"].ToString();
SurveyLength = read["SurveyLength"].ToString();
SurveyMemo = read["SurveyMemo"].ToString();
SurveyStatus = read["SurveyStatus"].ToString();
string sql1 = "select * from surveylog where Username='wangyi1687' and SurveyID='" + SurveyID + "'";
con = new SqlConnection(connstr);
con.Open();
SqlCommand com1 = new SqlCommand(sql1, con);
SqlDataReader reader = com1.ExecuteReader();
if (reader.Read())
{
SurveyStatus2 = reader["SurveyStatus"].ToString();
con = new SqlConnection(connstr);
string sql2 = "select * from survey where SurveyID='" + SurveyID + "'";
//创建SqlDataAdapter对象,调用sql
SqlDataAdapter myadapter = new SqlDataAdapter(sql2, con);
//创建并填充DataSet
myadapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (SurveyStatus2 == "有效")
{
//GridView1中显示字段的位置,假如在第5列就用e.Row.Cells[4].Text
e.Row.Cells[6].Text = "<a href=CategoryInfoInfo.aspx?SurveyID=" + SurveyID + ">有效</a>";
}
if (SurveyStatus2 == "完成")
{
e.Row.Cells[6].Text = "完成";
}
if (SurveyStatus2 == "失败")
{
e.Row.Cells[6].Text = "失败";
}
if (SurveyStatus2 == "进行中")
{
e.Row.Cells[6].Text = "进行中";
}
}
}
现在问题出在,绑定完数据后,第2条数据把第1条的e.Row.Cells[6].Text的值覆盖了