Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.Page
Imports shopping.classConnection
Partial Class userdetail
Inherits System.Web.UI.Page
Dim cmd As New SqlCommand()
Dim con As New shopping.classConnection()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
userdetail()
End If
End Sub
Private Function userdetail()
Dim adpuserdetail As New SqlDataAdapter
Dim dsuserdetail As New Data.DataSet
cmd.CommandText = "select * from tblUserDetail order by userid"
cmd.Connection = con.createConnection(Session("site"))
adpuserdetail.SelectCommand = cmd
adpuserdetail.Fill(dsuserdetail)
grduserdetail.DataSource = dsuserdetail
grduserdetail.DataBind()
End Function
Protected Sub grduserdetail_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grduserdetail.RowEditing
grduserdetail.EditIndex = e.NewEditIndex
userdetail()
End Sub
Protected Sub grduserdetail_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles grduserdetail.RowUpdating
Dim varuserid As Int32 = CType(grduserdetail.Rows(e.RowIndex).FindControl("userid"), Label).Text
Dim struserTitle As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("usertitle"), TextBox).Text
Dim strfirstName As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("firstname"), TextBox).Text
Dim strsurname As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("surname"), TextBox).Text
Dim straddress1 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address1"), TextBox).Text
Dim straddress2 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address2"), TextBox).Text
Dim straddress3 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("address3"), TextBox).Text
Dim strcity As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("city"), TextBox).Text
Dim strpostCode As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("postCode"), TextBox).Text
Dim strcountry As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("country"), TextBox).Text
Dim strphone1 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("phone1"), TextBox).Text
Dim strphone2 As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("phone2"), TextBox).Text
Dim strusername As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("username"), TextBox).Text
Dim strpassword As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("password"), TextBox).Text
Dim strstatus As Char = CType(grduserdetail.Rows(e.RowIndex).FindControl("status"), TextBox).Text
Dim strdate As Date = CType(grduserdetail.Rows(e.RowIndex).FindControl("date1"), TextBox).Text
Dim strsaveas As String = CType(grduserdetail.Rows(e.RowIndex).FindControl("saveas"), TextBox).Text
Dim varprefrence As Int32 = CType(grduserdetail.Rows(e.RowIndex).FindControl("prefrence"), TextBox).Text
'Dim boolActive As Boolean = CType(grduserdetail.Rows(e.RowIndex).FindControl("check"), CheckBox).Checked
'Dim varactive As Int32
'If boolActive = True Then
' varactive = 1
'ElseIf boolActive = False Then
' varactive = 0
'End If
cmd.CommandText = "update tblUserDetail set userTitle='" & struserTitle & "', firstName ='" & strfirstName & "', surname ='" & strsurname & "', address1='" & straddress1 & "', address2='" & straddress2 & "', address3 ='" & straddress3 & "', city='" & strcity & "', postCode ='" & strpostCode & "',country='" & strcountry & "', phone1 ='" & strphone1 & "',phone2 ='" & strphone2 & "',username ='" & strusername & "',password='" & strpassword & "', status ='" & strstatus & "', date=" & strdate & ", saveas ='" & strsaveas & "',prefrence =" & varprefrence & " where userid =" & varuserid
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
grduserdetail.EditIndex = -1
userdetail()
End Sub
Protected Sub grduserdetail_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles grduserdetail.RowCancelingEdit
grduserdetail.EditIndex = -1
userdetail()
End Sub
End Class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment