我用FOR循环遍历检索Girdview中CheckBox是否被选中,但是无法实现!开始我以为是语句错误,然后我用response.write()返回搜索结果,但是我选中的CheckBox的Checked状态都为False这是怎么回事,但是我想了好久,逻辑方面没有什么问题啊!遍历的语法也没有用错.请高手指教
protected void Button1_Click(object sender, EventArgs e)
{
all.DCommd=new System.Data.OleDb.OleDbCommand();
int GridRows = Convert.ToInt32(GridView1.Rows.Count);
int i;
for (i = 0; i < GridRows; i++)
{
int Count = Convert.ToInt32(all.MySet.Tables[DataStr_1].Rows[i].ItemArray[0]);
String Command;
if (((CheckBox)GridView1.Rows[i].FindControl("DelCheck")).Checked)
{
Command = "DELETE FROM LeText WHERE LeText_ID=" + Convert.ToString(Count);
Select.DC(Command, all.MyConn);
all.MyConn.Open();
all.DCommd.ExecuteNonQuery();
all.MyConn.Close();
}
}
}这是原代码!