for (int i=0; i < MyList.Items.Count; i++) { Label lblProductID = (Label) MyList.Items[i].FindControl("ProductID"); CheckBox remove = (CheckBox) MyList.Items[i].FindControl("Remove");
if (remove.Checked == true) { //对lblProductID.Text的对象进行处理。 } }
Dim i As Int32 Dim cb As CheckBox Dim n As Int32 = MyDataGrid.Items.Count - 1 For i = 0 To n cb = CType(MyDataGrid.Items(i).Cells(1).FindControl("chkDelete"), CheckBox) If cb.Checked = True Then strupdate = "delete T_CARD where ID ='" & MyDataGrid.Items(i).Cells(0).Text() & "'" comm = New SqlCommand(strupdate, objcn) objcn.Open() comm.ExecuteNonQuery() objcn.Close() Next BindGrid()
{
Label lblProductID = (Label) MyList.Items[i].FindControl("ProductID");
CheckBox remove = (CheckBox) MyList.Items[i].FindControl("Remove");
if (remove.Checked == true)
{
//对lblProductID.Text的对象进行处理。
}
}
Dim cb As CheckBox
Dim n As Int32 = MyDataGrid.Items.Count - 1
For i = 0 To n
cb = CType(MyDataGrid.Items(i).Cells(1).FindControl("chkDelete"), CheckBox)
If cb.Checked = True Then
strupdate = "delete T_CARD where ID ='" & MyDataGrid.Items(i).Cells(0).Text() & "'"
comm = New SqlCommand(strupdate, objcn)
objcn.Open()
comm.ExecuteNonQuery()
objcn.Close()
Next
BindGrid()
1.自己建一个datatable,画面上的显示只对datatable操作,对datagrid用datatable绑定,不要频繁读写数据库.
2.最终批量删除的时候用事务.