Hi all...

I have a datagrid with values bound to it from a table..I have a check box in every row of the datagrid.If i check the check box and click the delete button present in the form,the checked row of the datagrid should be deleted(ultimately deleting the data from the database table itself)..If i check all the rows in the datagrid and click the delete button ,all the rows should be deleted..Someone help me in this regard..
Sample code would do more help...


Thanks in Advance...


Balaguru

Hi all...

I have a datagrid with values bound to it from a table..I have a check box in every row of the datagrid.If i check the check box and click the delete button present in the form,the checked row of the datagrid should be deleted(ultimately deleting the data from the database table itself)..If i check all the rows in the datagrid and click the delete button ,all the rows should be deleted..Someone help me in this regard..
Sample code would do more help...


Thanks in Advance...


Balaguru

Well hope this helps. But i used this for Asp.Net and it worked.

Sub Click_Grid(ByVal Sender as Object, ByVal E as DataGridCommandEventArgs)
    Dim TheID as String
    TheID = E.Item.Cells(1).Text
    Dim DBConn as OleDbConnection
    Dim DBDelete As New OleDbCommand
    DBConn = New OleDbConnection( _
        "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
        & "DATA SOURCE=" _
        & Server.MapPath("EmployeeDatabase.mdb;"))
    DBDelete.CommandText = "Delete From Employee Where " _
        & "ID = " & TheID
    DBDelete.Connection = DBConn
    DBDelete.Connection.Open
    DBDelete.ExecuteNonQuery()
    DBConn.Close
    BuildDataList
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.