我有一个带有四个模板字段的gridview,我需要能够将信息放入以保存到数据库中。当我点击编辑按钮并且我的列更改为编辑模式时,我可以很好地输入信息......但是当我尝试循环通过控件获取信息时,它什么也没得到?
Private Sub gvOLIAdj_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvOLIAdjst.RowEditing
gvOLIAdjst.EditIndex = e.NewEditIndex
BindData()
End Sub
这是我到目前为止的更新活动......有什么想法吗?我只是不这样做吗?
Private Sub gvOLIAdj_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvOLIAdjst.RowUpdating
Dim dts As DataTable = DirectCast(Session("BudgetsTable"), DataTable)
Dim row As GridViewRow = gvOLIAdjst.Rows(e.RowIndex)
If DirectCast(row.FindControl("txtItemTempTtlAmt"), TextBox).Text = "" Then
lblError.Text = "Invalid Entry. Correct and try again"
e.Cancel = True
Else
lblError.Text = ""
dts.Rows(row.DataItemIndex)("Approval Date") = DirectCast(row.FindControl("txtItemTempApprDt"), TextBox).Text
dts.Rows(row.DataItemIndex)("Total Amount") = DirectCast(row.FindControl("txtItemTempTtlAmt"), TextBox).Text
dts.Rows(row.DataItemIndex)("Comments") = DirectCast(row.FindControl("txtItemTempCmmt"), TextBox).Text
dts.Rows(row.DataItemIndex)("Initials") = DirectCast(row.FindControl("lblItemTempInit"), Label).Text
gvOLIAdjst.EditIndex = -1
BindData()
End If
If Not IsPostBack Then
result = dal.dbConnect(sqlconnection, ConfigurationManager.AppSettings("SQLServerConnection"))
If result = "Successful" Then
dt = ExecuteInsertUpdateDeleteStoredProc(sqlconnection, "@amt", txtItemTempApprDt.text)
dbClose
End If
End If
End Sub