.net中怎么在点击确定提交按钮后,让gridview1的数据移到gridview2里去,同时对应数据在gridview1里面消失
主要后台代码for(i=0;i<GridView1.Rows.Count;i++){score=int.Parse(((TextBox)GridView1.Rows[i]...
主要后台代码
for (i = 0; i < GridView1.Rows.Count; i++)
{
score = int.Parse(((TextBox)GridView1.Rows[i].FindControl("txtScore")).Text.Trim());//取出学生成绩
stuID = GridView1.Rows[i].Cells[0].Text;
strUpdate = "update Elect set Score=" + score + " where stuID='" + stuID + "' and courceID='" + courceID + "' and teaID='" + teaID + "'";
try
{
SqlCommand cmd = new SqlCommand(strUpdate, conn);//创建Command对象
flag = cmd.ExecuteNonQuery(); //执行添加成绩操作
cmd.Dispose();
}
catch (Exception ex) //异常处理
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
if (conn.State.ToString() == "Open") //如果连接打开,关闭
conn.Close(); 展开
for (i = 0; i < GridView1.Rows.Count; i++)
{
score = int.Parse(((TextBox)GridView1.Rows[i].FindControl("txtScore")).Text.Trim());//取出学生成绩
stuID = GridView1.Rows[i].Cells[0].Text;
strUpdate = "update Elect set Score=" + score + " where stuID='" + stuID + "' and courceID='" + courceID + "' and teaID='" + teaID + "'";
try
{
SqlCommand cmd = new SqlCommand(strUpdate, conn);//创建Command对象
flag = cmd.ExecuteNonQuery(); //执行添加成绩操作
cmd.Dispose();
}
catch (Exception ex) //异常处理
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
if (conn.State.ToString() == "Open") //如果连接打开,关闭
conn.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询