1

全部。我有一个带有列的数据网格视图。我需要能够将空白行添加到已经填充的网格中。我有 10 个文本框以及一个“添加”按钮。在按钮单击事件时,它应该将空白行添加到 datagridview,但是,它不能正常工作。我没有收到任何类型的错误,而且我的代码似乎没问题。请提前感谢您的帮助。

这是我的代码背后。默认.aspx.vb

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
End Sub

Protected Sub Operations_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) _
Handles Operations.RowCommand
Insert data if the CommandName == "Insert"
and the validation controls indicate valid data...
    If e.CommandName = "Insert" AndAlso Page.IsValid Then
        Insert(New record)
        SQLDATASOURCE1.Insert()
    End If
End Sub


Protected Sub SQLDATASOURCE1_Inserting _
(sender As Object, e As .ObjectDataSourceMethodEventArgs) _
Handles SQLDATASOURCE1.Inserting
    Dim OPN_NUMBER As TextBox = _
    Operations.FooterRow.FindControl("OPN_NUMBER")
    Dim OPN_Desc As TextBox = _
    Operations.FooterRow.FindControl("OPN_DESC")
    Dim OPN_GL_ACCT As Textbox = _
    Operations.FooterRow.FindControl("OPN_GL_ACCT")
    Dim OPN_COST_CENTER As TextBox = _
    Operations.FooterRow.FindControl("OPN_COST_CENTER")
    Dim OPN_IND_LABOR As TextBox = _
    Operations.FooterRow.FindControl("OPN_IND_LABOR")
    Dim OPN_DIR_LABOR As TextBox = _
    Operations.FooterRow.FindControl("OPN_DIR_LABOR")
    Dim OPN_Non_OT As TextBox = _
    Operations.FooterRow.FindControl("OPN_NON_OT")
Dim OPN_STATUS As TextBox =_
    Operations.FooterRow.FindControl("OPN_STATUS")
    Dim OPN_UPDATED As TextBox = _
    Operations.FooterRow.FindControl("OPN_UPDATED")
    Dim OPN_UPDATED_BY As TextBox = _
    Operations.FooterRow.FindControl("OPN_UPDATED_BY")

End Sub
4

0 回答 0