try
{
int intCount = this.GridView1.Rows.Count;
for (int i = 0; i < intCount; i++)
{
CheckBox CheckSingle = this.GridView1.Rows[i].Cells[11].FindControl("itemchk") as CheckBox;
if (CheckSingle.Checked)
{
int id = Convert.ToInt32((GridView1.Rows[i].FindControl("lblId") as Label).Text);
strcon.Open();
SqlCommand cmd = new SqlCommand("update ComTickEt_M Set PayId=6 where ID='" + id + "'", strcon);
cmd.ExecuteNonQuery();
this.Panel1.Visible = true;
this.Labmessage.Text = "修改订单状态成功";
} } this.GetData();
}
catch
{
}
finally
{
strcon.Close();
}
是哪出错了.一次不管选择几个只能改一个.
{
int intCount = this.GridView1.Rows.Count;
for (int i = 0; i < intCount; i++)
{
CheckBox CheckSingle = this.GridView1.Rows[i].Cells[11].FindControl("itemchk") as CheckBox;
if (CheckSingle.Checked)
{
int id = Convert.ToInt32((GridView1.Rows[i].FindControl("lblId") as Label).Text);
strcon.Open();
SqlCommand cmd = new SqlCommand("update ComTickEt_M Set PayId=6 where ID='" + id + "'", strcon);
cmd.ExecuteNonQuery();
this.Panel1.Visible = true;
this.Labmessage.Text = "修改订单状态成功";
} } this.GetData();
}
catch
{
}
finally
{
strcon.Close();
}
是哪出错了.一次不管选择几个只能改一个.
或 if (CheckSingle.Checked = true )2 断点 this.Labmessage.Text = "修改订单状态成功";
跟踪 看循环进了几次? 查看各个值是否正常?
int id = Convert.ToInt32((GridView1.Rows[i].FindControl("lblId") as Label).Text);
天啊才发现 int id
update ComTickEt_M Set PayId=6 where ID='" + id + "'", strcon 加 id ='? '
加 id ='? '
改
update ComTickEt_M Set PayId=6 where ID=" + id , strcon 加 id ='? '
如果不行再
update ComTickEt_M Set PayId=6 where ID='" + id.Tostring.Trim() + "'", strcon 加 id ='? '
catch (Exception ex)
{
throw ex;
}看看抛出什么信息?
有可能strcon.Open();这里会出错?打开多次,未关闭?
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
this.dataGridView1.Rows.Add(i.ToString(), "True");
}
} private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.dataGridView1.Rows.Count-1 ; i++)
{
if (this.dataGridView1.Rows[i].Cells[1].Value.ToString() == "True")
{
MessageBox.Show(this.dataGridView1.Rows[i].Cells[0].Value.ToString());
}
}
}我实验了下这么循环可以循环
有可能strcon.Open();这里会出错?打开多次,未关闭?
是没错的