16,555
社区成员
发帖
与我相关
我的任务
分享
Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim id As Integer
Dim row As Integer
Dim username As String
Dim pasword As String
Dim sex As String
Dim borthday As String
Dim datateble As DataTable
Dim update As userSee
update = New userSee
Dim dao = New daoceng.dao
Dim sqlselect = New String("select * from rggltest.dbo .Do_not_BB where Id =@id")
Dim sql = New String("update Do_not_BB set Pasword=@pasword,Username=@username,sex=@sex,borthday=@borthday where Id=@id")
id = GridView1.Rows(e.RowIndex).Cells(0).Text.ToString
'根据点击编辑查询所对应的所有信息,返回一个datetable
datateble = dao.selecton(update.Connection, sqlselect, id.ToString)
'如果输入的值为nothing,那就把查询出来的password赋值给后台
If (GridView1.Rows(e.RowIndex).Cells(1).Text.ToString Is Nothing) Then
pasword = datateble.Rows(0)("pasword")
Else
'这个是我准备取前台更新的代码。但是不知道对不对,而且不懂这条语句怎么搞的
pasword = GridView1.Rows(e.RowIndex).Cells(1).Text.ToString
End If
‘我就想要获取gridvivw对应的某行里面的某一列值(在更新的时候)
‘看到这儿就够了下面的都是一样的,代码有点乱,也证明我的思路有点乱,还请各位大佬多多担待一下
If (GridView1.Rows(e.RowIndex).Cells(2).Text.ToString Is Nothing) Then
username = datateble.Columns("username").ToString
Else
username = GridView1.Rows(e.RowIndex).Cells(2).Text.ToString
End If
If (GridView1.Rows(e.RowIndex).Cells(3).Text.ToString Is Nothing) Then
sex = datateble.Columns("sex").ToString
Else
sex = GridView1.Rows(e.RowIndex).Cells(3).Text.ToString
End If
If (GridView1.Rows(e.RowIndex).Cells(4).Text.ToString Is Nothing) Then
borthday = datateble.Columns("borthday").ToString
Else
borthday = GridView1.Rows(e.RowIndex).Cells(4).Text.ToString
End If
row = dao.update(update.Connection, sql, id, pasword, username, sex, borthday)
If (row > 0) Then
Response.Redirect("/aspx/userSee.aspx")
End If
End Sub
Protected Sub gridView1_RowCanceLingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
Response.Redirect("/aspx/userSee.aspx")
End Sub