[code=C#][/code] <asp:ButtonField ButtonType="Button" CommandName="second" Text="第二志愿" >
<ItemStyle Wrap="False" />
</asp:ButtonField>
后台代码[code=C#][/code] protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "first")
{
int i = Int32.Parse((string)e.CommandArgument);
string s = GridView1.Rows[i].Cells[0].Text;
string strconn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\毕业设计管理系统1\App_Data\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string sql = @"select * from [assignment] where assignmentname='" + s + "'";
SqlCommand strcom = new SqlCommand(sql, conn);
SqlDataReader sqlread = strcom.ExecuteReader();
string strconn1 = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\毕业设计管理系统1\App_Data\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn1 = new SqlConnection(strconn1);
conn1.Open();
while (sqlread.Read())
{
string strsql1 = @"INSERT INTO [diyizhiyuan] (assignmentid, assignmentname,assignment_teacher,assignment_source,assignment_leibie,assignment_neirong,assignment_require,
assignment_chengguo,xueyuan,tzhiwu,assignment_xnum, assignment_snum,tid,time)
VALUES('" + sqlread[0].ToString() + "','" + sqlread[1].ToString() + "','" + sqlread[2].ToString() + "','" + sqlread[3].ToString() + "','" + sqlread[4].ToString() + "','" + sqlread[5].ToString() + "','" + sqlread[6].ToString() + "','" + sqlread[7].ToString() + "','" + sqlread[8].ToString() + "','" + sqlread[9].ToString() + "','" + sqlread[10].ToString() + "','" + sqlread[11].ToString() + "','" + sqlread[12].ToString() + "','" + sqlread[13].ToString() + "')";
//sqlcmd1.CommandText = strsql1;
SqlCommand sqlcom1 = new SqlCommand(strsql1, conn1);
sqlcom1.ExecuteNonQuery();
}
conn1.Close();
conn.Close();
}
else if (e.CommandName == "second")
{
int j = Int32.Parse((string)e.CommandArgument);
string s = GridView1.Rows[j].Cells[0].Text;
string strconn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\毕业设计管理系统1\App_Data\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string sql = @"select * from [assignment] where assignmentname='" + s + "'";
SqlCommand strcom = new SqlCommand(sql, conn);
SqlDataReader sqlread = strcom.ExecuteReader();
Label1.Text = "<script language=javascript>alert('确定该课题审核未通过?');</script>";
string strconn1 = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\毕业设计管理系统1\App_Data\database.mdf;Integrated Security=True;User Instance=True";
SqlConnection conn1 = new SqlConnection(strconn1);
conn1.Open();