嗨,我对我的gridview的复选框有这个问题,在选中复选框后,所有选中的行都应该在单击重新分配按钮的地方重新分配。但它只是重新检查了第一个项目,似乎它没有循环通过gridview。你能帮我找出我的代码中的错误或缺失吗:
protected void Reassign_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in ParticularWorkGridView.Rows)
{
CheckBox _checkBox = (CheckBox)row.FindControl("ReassignCheckBox");
Label _RecordNumberLabel = (Label)row.FindControl("NumberLabel");
if (_checkBox != null &&
_checkBox.Checked == true)
{
SqlConnection con = new SqlConnection(GetConnectionString());
SqlCommand cmd = new SqlCommand("[Reassig]", con);
cmd.CommandType = CommandType.StoredProcedure;
string MemberID = DropDrownList.SelectedValue;
cmd.Parameters.AddWithValue("number", _NumberLabel.Text);
cmd.Parameters.AddWithValue("@MemberID", MemberID);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
con.Close();
cmd.Dispose();
Response.Redirect("ParticularWork.aspx");
}
}
}
谢谢