


















前2天我做的财务管理系统中需要用到datagrid控件来显示用户信息,为了能够编辑用户信息,我参照微软的asp.net入门套件ASP.NET Time Tracker Starter Kit (VBVS)中在datagrid中使用编辑模版。 在问题没解决之前,点击datagrid中的编辑始终报下面错误:
’==================
‘===================
下面是datagrid的html文件:
最初的页面显示如下:
按下编辑后的页面:
对于编辑列中的edit,update,cancel需要用到下面的是件:
'编写从 DropDownList 中检索当前选定值的代码,并执行数据库更新
Protected Sub dguserdetail_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dguserdetail.UpdateCommand
Dim item As DataGridItem = dguserdetail.Items(dguserdetail.EditItemIndex)
If e.CommandName = "Update" Then
If e.Item.ItemType = ListItemType.EditItem Then '只有在编辑按下以后才能提交
Dim username As String
Dim password As String
Dim email As String
Dim authority As String
Dim authorityId As Integer
username = CType(e.Item.FindControl("username"), Label).Text
password = CType(e.Item.FindControl("txtpassword"), TextBox).Text
email = CType(e.Item.FindControl("txtemail"), TextBox).Text
authority = CType(e.Item.FindControl("ddauthority"), DropDownList).SelectedItem.Value
authorityId = IIf(authority = "系统管理员", 1, 0)
' Save the dguserdetail object.
Try
SqlHelper.ExecuteNonQuery(strconn, "updateuser", username, password, email, authorityId)
Catch
End Try
End If
' Quit in-line-editing mode.
dguserdetail.EditItemIndex = -1
SetBind()
End If
End Sub
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。