Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting row from datagrid
Message
From
08/12/2002 13:00:12
 
 
To
08/12/2002 12:59:14
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00730717
Message ID:
00730727
Views:
15
Sorry the comment on the last line is wrong, it should have been something like 'Redisplay grid data.

Aloha,

James
>Hey Allan,
>
>I'm not absolutly sure on all the details but here's my theory:
>
>
>Private Sub DataGrid1_DeleteCommand(ByVal source As Object, _
>ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
>Handles DataGrid1.DeleteCommand
>   Dim PKey As Integer
>   iPKey = e.Items.Cells[1].Text
>
>   'Code to get a connection to the Access database
>   SQLString = "Delete BlahBlahBlah Where PKey = " + Str(iPKey)
>   oConnection = New OleDbConnection(???)
>   oCommand = New OleDbCommand(SQLString, oConnection)
>
>   'Now delete the record
>   oConnection.Open()
>   oCommand.ExecuteNonQuery()
>   oConnection.Close()
>
>   ' Add code to delete data from data source.
>   subFillGrid()
>End Sub
>
>
>
>
>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform