Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting row from datagrid
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Deleting row from datagrid
Miscellaneous
Thread ID:
00730717
Message ID:
00730717
Views:
53
Hi,

I have a datagrid in which I've added a delete button on one of my webforms. The code I'm using to populate the grid from an Access DB (sorry, it couldn't be avoided ...) looks like this:
Sub subFillGrid()

Dim objConn As OleDb.OleDbConnection = New OleDb.OleDbConnection()
Dim Adapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter()
Dim dsDataDict As Data.DataSet = New Data.DataSet()
Dim strConn, strSQL As String

If ConfigurationSettings.AppSettings("AppMode") = "ModeProd" Then
    strConn = ConfigurationSettings.AppSettings("dbConnectLive")
ElseIf ConfigurationSettings.AppSettings("AppMode") = "ModeTest" Then
    strConn = ConfigurationSettings.AppSettings("dbConnectTest")
End If

strSQL = "Select FirstNameVC, LastNameVC, EMailVC, DateDT from BlahBlahBlah"

objConn.ConnectionString = strConn
Adapter.SelectCommand = New OleDb.OleDbCommand(strSQL, objConn)
Adapter.SelectCommand.Connection.Open()
Adapter.Fill(dsDataDict, "FileReg")
DataGrid1.DataSource = dsDataDict.Tables("FileReg")
DataGrid1.DataBind()
End Sub
The grid gets populated just fine.

Now I'm trying to figure out how to code this event. The help that I found was limited (I may not have been looking in the right place ...)
' Visual Basic
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles DataGrid1.DeleteCommand
   Dim index As Integer
   index = e.Item.ItemIndex
   ' Add code to delete data from data source.
   DataGrid1.DataBind()
End Sub
I'm thinking that I need to do something with a DataRow - but I'm stumped. Any suggestions on the code I should use to delete the row from the DataTable and the underlying database itself would be appreciated
Al Williams

Anola MB, CANADA
Next
Reply
Map
View

Click here to load this message in the networking platform