根据checkbox选中的Gridview的某一行的id值对其中的某一字段值增1数据库没改变
for(inti=0;i<GridView1.Rows.Count-1;i++){CheckBoxcbox=(CheckBox)GridView1.Rows[i].Fin...
for (int i = 0; i < GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
if (cbox.Checked == true)
{
string a = GridView1.Rows[i].Cells[0].Text.ToString();
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=VoteOnline;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("Update 恋爱观点 set 投票数量=投票数量+1 where ID='a'", con);
cmd.ExecuteNonQuery();
}
} 展开
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
if (cbox.Checked == true)
{
string a = GridView1.Rows[i].Cells[0].Text.ToString();
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=VoteOnline;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("Update 恋爱观点 set 投票数量=投票数量+1 where ID='a'", con);
cmd.ExecuteNonQuery();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询