DataGridview 및 gridview 첫 번째 열에는 확인란이 포함되어 있고 확인란을 선택하고 싶습니다. 나에게 예외를주는 C#에서 응용 프로그램을 개발 중입니다. 객체 참조가 객체의 인스턴스로 설정되지 않았습니다. ' 코드는 다음과 같습니다gridview 열 확인 확인란
private void btnDelete_Click(object sender, EventArgs e)
{
StudentDAL s = new StudentDAL();
try
{
for (int i = 0; i < this.dataGridView1.RowCount; i++)
{
if (!DBNull.Value.Equals(this.dataGridView1.Rows[i].Cells[0]) && (bool)this.dataGridView1.Rows[i].Cells[0].Value == true)
{
s.delete(Convert.ToInt32(this.dataGridView1.Rows[i].Cells[1].Value));
i--;
}
}
this.dataGridView1.DataSource = s.getAll();
}
catch (Exception nn)
{
}
}
도와주세요.
당신은'에 의해 먼저 체크 박스 제어를 얻어야한다 FindControl()'메서드를 호출 한 후 검사 여부를 확인하십시오. –