datagrid启用修改后,对textbox修改为什么无法获得修改后的值?

zjs_sql zjs_sql 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
datagrid启用修改后,对textbox修改,为什么无法获得修改后的值?
Dim NumCols As Integer = E.Item.Cells.Count
Dim CurrentTextBox As TextBox
Dim ColValue As String
CurrentTextBox = E.Item.Cells(2).Controls(0)
ColValue = CurrentTextBox.Text
还是未得到修改的值!!================================================================
Sub MyDataGrid_Update(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim myconn As OleDb.OleDbConnection = New OleDbConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=works;Data Source=.")
Dim zw As String
Dim bmzyzs As String
Dim ids As String




Dim NumCols As Integer = E.Item.Cells.Count
Dim CurrentTextBox As TextBox
Dim ColValue As String
CurrentTextBox = E.Item.Cells(2).Controls(0)
ColValue = CurrentTextBox.Text

Response.Write(ColValue)
Response.End()
' 检查在所需字段中是否有空值

If ColValue = "" Then
Label1.Text = "错误:""职务""不允许使用空值"
Label1.Style("color") = "red"
Return
Else
zw = ColValue
End If


CurrentTextBox = E.Item.Cells(3).Controls(0)
ColValue = CurrentTextBox.Text
' 检查在所需字段中是否有空值
If ColValue = "" Then
Label1.Text = "错误:""部门重要指数""不允许使用空值"
Label1.Style("color") = "red"
Return
Else
bmzyzs = ColValue
End If



ColValue = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
' 检查在所需字段中是否有空值
If ColValue = "" Then
Label1.Text = "错误:""ID""不允许使用空值"
Label1.Style("color") = "red"
Return
Else
ids = ColValue
End If


Dim UpdateCmd As String = "UPDATE 公司职务 SET 职务='" + zw + "',部门重要指数=" + bmzyzs + " where 编号 = " + ids
Dim MyCommand As OleDbCommand = New OleDbCommand(UpdateCmd, myconn)
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Label1.Text = "已更新记录" & UpdateCmd.ToString()
MyDataGrid.EditItemIndex = -1
BindGrid()
Catch Exp As OleDbException
Label1.Text = "错误:未能更新记录,请确保正确填写了字段" + Exp.Source + Exp.Message

Label1.Style("color") = "red"
End Try
MyCommand.Connection.Close()


End Sub
...全文
评论 2
收藏 已收藏
分享
返回顶部
zjs_sql
.NET社区 62,273 成员 668,968 内容