索引超出范围。必须为非负值并小于集合大小。

PartialClassadmin_manageUsersInheritsSystem.Web.UI.PageSubgvDataBind()Me.GridView1.Da... Partial Class admin_manageUsers
Inherits System.Web.UI.Page
Sub gvDataBind()
Me.GridView1.DataSource = SqlDataSource1
Me.GridView1.DataSource = Membership.GetAllUsers()
Me.GridView1.DataBind()
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
gvDataBind()
Me.tbRoles.Visible = False
End If
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
Me.GridView1.EditIndex = e.NewEditIndex
gvDataBind()
End Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim IsApproved As Boolean = CType(Me.GridView1.Rows(e.RowIndex).Cells(1).FindControl("chkIsApproved"), CheckBox).Checked
Dim Email As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(2).FindControl("txtEmail"), TextBox).Text
Dim Comment As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(3).FindControl("txtComment"), TextBox).Text
Dim OldUserName As String = Me.GridView1.DataKeys(e.RowIndex).Value(提示超出范围)
Dim CurrentUser As MembershipUser = Membership.GetUser(OldUserName)
CurrentUser.IsApproved = IsApproved
CurrentUser.Email = Email
CurrentUser.Comment = Comment
Membership.UpdateUser(CurrentUser)
Me.GridView1.EditIndex = -1
Me.gvDataBind()
End Sub
Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
Me.GridView1.EditIndex = -1
gvDataBind()
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim UserName As String = Me.GridView1.DataKeys(e.RowIndex).Value(提示超出范围)
Membership.DeleteUser(UserName)
Me.GridView1.EditIndex = -1
Me.gvDataBind()
End Sub
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate Then
If e.Row.Cells(5).Controls.Count <> 0 Then
Dim btnDelete As LinkButton = e.Row.Cells(5).Controls(0)
If btnDelete IsNot Nothing Then
btnDelete.Attributes("onclick") = "return confirm('你确实要删除这个用户吗?')"
End If
End If
End If
End Sub
这个问题怎么解决啊???哪位大侠站出来帮一下忙,小弟感激不尽啊...
展开
 我来答
匿名用户
2009-12-05
展开全部
多半是没有设置DataKeys,你在GV1的属性栏中找到“数据项”,然后在设置一下表的DataKeys为usesname试试
百度网友b6eaad0d9
2009-12-03
知道答主
回答量:15
采纳率:0%
帮助的人:0
展开全部
调试
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式