Problem updating a DataGrid
I have set up a Datagrid, with one column editable. The button BtnWrite_CLick has a click event procedure which is intended to writeh the changes to the Database. But I have a problem getting it to compile.
If I write my procedure as follows:-
Public Sub BtnWrite_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnWrite.Click
Dim objConnection As OleDb.OleDbConnection
Dim objCommand As OleDb.OleDbDataAdapter
Dim objAdapter As OleDb.OleDbDataAdapter
Dim objBuilder As OleDb.OleDbCommandBuilder
Dim strConnect As String
Dim strCommand As String
Dim strDIP As String
Dim dgi As DataGridItem
Dim datedsn As String
For Each dgi In DgSTDPE.Items
'DisplayBoundColumnValues(a, e)
Dim DSNkey As String = e.Item.Cells(0) ' this line is highlighted as an Error
'Dim a As TableCell = DgSTDPE.Columns.Item
Try
datedsn = Request.QueryString("t_dsn")
StrDemDate = datedsn.Substring(0, 6)
StrDemNo = datedsn.Substring(7, 4)
Dim newQty As String = CType(dgi.FindControl("demand_qty"), TextBox).Text
Dim DataSet2 As New DataSet
strCommand = "exec dbo.USp_STDPD_Update '" & StrDemDate & "','" & StrDemNo & "','" & newQty & "'"
objConnection = New OleDb.OleDbConnection(strConn)
objCommand = New OleDb.OleDbDataAdapter(strCommand, objConnection)
objCommand.Fill(DataSet2, "due_in")
Dim objDataView As New DataView(DataSet2.Tables("due_in"))
Catch ex As Exception
LblApprepLine.Text = "Datedsn = " & datedsn
End Try
Next
End Sub
the line shown in red is high-lighted by the compiler. If I change the first line to:-
Public Sub BtnWrite_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles BtnWrite.Click
then the bit shown in red gets flagged as an error.
So what do I do?
|