http://dotnet.aspx.cc/ShowDetail.aspx?id=FF130C7F-3650-4DA6-8943-8AA4AF3E3459

解决方案 »

  1.   


    Sub btnDel_OnClick(ByVal sender As Object, ByVal e As EventArgs)
        Dim myDataGridItem_del As DataGridItem
        Dim chkSelected_del As System.Web.UI.WebControls.CheckBox
        Dim strBoardType_del As String
        Dim strBoardID_del As String
     
        lblSelect.Text = "<br>You selected the Following items:<br><br>"
        lblStatus.Text=""
        For Each myDataGridItem_del In MyDataGrid.Items
            chkSelected_del = myDataGridItem_del.FindControl("chkSelection")
            If chkSelected_del.Checked Then
       lblSelect.visible=true
               strBoardType_del= CType(myDataGridItem_del.FindControl("lblBoardType"), Label).Text
               strBoardID_del = CType(myDataGridItem_del.FindControl("hdnBoardid"), Label).Text
    '--------------------------------------------
            Dim MyDelCommand As OleDbCommand
            Dim DeleteCmd As String = "DELETE FROM [min] WHERE id = @Id"        MyDelCommand = New OleDbCommand(DeleteCmd, MyConnection)
            MyDelCommand.Parameters.Add(New OleDbParameter("@Id", OleDbType.VarChar, 11))
            MyDelCommand.Parameters("@Id").Value = int32.parse(strBoardID_del)        MyDelCommand.Connection.Open()
            MyDelCommand.ExecuteNonQuery()
            MyDelCommand.Connection.Close()
    '---------------------------------------------
                    lblStatus.Text += "The id is Deleted<b>" & strBoardType_del & "</b>"
                    lblStatus.Text += " and the id is Deleted<b>" & strBoardID_del & "</b><br>"
                else
        lblSelect.visible=false
                End If
            Next
        try    
            BindDataGrid()
        catch
            Mydatagrid.CurrentpageIndex=MyDataGrid.pagecount-1
            BindDataGrid()
        end try
        End Sub
      

  2.   

    楼上的能不能提供一个c#的例子啊?或者旧在我得那个例子上改易下,我看不懂vb啊,谢了!
      

  3.   

    把int i=0改成int i=dg.items.count-1
    i++改成i--
    试试
      

  4.   

    会不会是这句错误
    cb = (CheckBox) dgi.Cells[0].Controls[1];
    cell[0]改成cell[1],controls里的index也改一下试试
      

  5.   

    我刚装的系统,没装.net啊
    感觉是index的问题
    cell[0].controls[0]
    试试
      

  6.   

    他说指定的转换无效
    异常详细信息: System.InvalidCastException: 指定的转换无效。源错误: 
    行 106: {
    行 107:
    行 108: cb = (CheckBox) dgi.Cells[0].Controls[0];
    行 109:
    行 110: if(cb.Checked==true
     
      

  7.   

    那可能就是1楼说得问题了
    你去google搜索一下试试
    或者看看这个
    http://expert.csdn.net/Expert/topic/2995/2995178.xml?temp=.1162683
    里面站点很多,你以后也用的到