我想要如果 gridview 中的 checkbox1 被选中,那么 gridview 中的 label1 文本是 Block 如果 gridview 中的 checkbox1 未被选中,那么 label1 text n gridview 被取消阻止...
我想这样做是因为想要....阻止在 ASPNETDB.MDF 成员资格表中取消阻止用户。..
这段代码有什么问题:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Dim linkbutton1 As LinkButton = Me.GridView1.SelectedRow.FindControl("LinkButton1")
Dim chk As CheckBox = Me.GridView1.SelectedRow.FindControl("CheckBox1")
If chk.Checked = True Then
linkbutton1.Text = "Block"
Dim user As MembershipUser = Membership.GetUser(GridView1.SelectedRow.Cells(1).Text.ToString)
'To block a specific user:
user.IsApproved = False
Membership.UpdateUser(user)
Else
linkbutton1.Text = "UnBlock"
Dim user As MembershipUser = Membership.GetUser(GridView1.SelectedRow.Cells(1).Text.ToString)
'To block a specific user:
user.IsApproved = True
Membership.UpdateUser(user)
End If
End Sub