A SQL connection on the aspx page fills the listbox. I click on a
name in the list box and on postback it fills the eight objects.
On click of btnUpdate the object are not found for the update. I have
tried form.findcontrol as you will notice commented out below as well
as various other solutions. I know that the update works because all
but these four get updated:
1. varTier = txtTier.Text
2. varWorkPhone2 = txtWorkPhone.Text
3. varHomePhone2 = txtHomePhone.Text
4. varMobilePhone2 = txtMobilePhone.Text
Any help would be much appreciated. I really need to complete this by
Monday.
Thank you and don't forget Mother's Day this Sunday,
TheWall
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.Data.Sql
Imports System.Data
Imports System.Web.Mail
Imports System.Web.Configuration
Imports System.Collections.CollectionBase
Partial Class CallTree
Inherits
System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim connectionString As String =
System.Configuration.ConfigurationManager.ConnectionStrings("RCSConnectionString").ConnectionString
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim SQLstr As String
Dim varStaffName As String
'Dim varWorkPhone2 As String
'Dim varHomePhone2 As String
'Dim varMobilePhone2 As String
Dim dr As SqlDataReader
'Dim varVCNUmber As String
varStaffName = lbFullName.SelectedValue.ToString
'varWorkPhone2 = txtWorkPhone.Text
'varHomePhone2 = txtHomePhone.Text
'varMobilePhone2 = txtMobilePhone.Text
If Page.IsPostBack Then
SQLstr = " SELECT "
SQLstr = SQLstr & " ISNULL(StaffID,'') As StaffID,
ISNULL(RegNumber,'') AS RegNumber, "
SQLstr = SQLstr & " ISNULL(VCNumber,'') AS VCNumber,
ISNULL(Position,'') AS Position, "
SQLstr = SQLstr & " ISNULL(FullName,'') AS FullName,
ISNULL(Tier,0) AS Tier, ISNULL(WorkPhone,'') AS WorkPhone, "
SQLstr = SQLstr & " ISNULL(HomePhone,'') AS HomePhone,
ISNULL(MobilePhone,'') AS MobilePhone "
SQLstr = SQLstr & " FROM tblCallTree "
SQLstr = SQLstr & " WHERE FullName = '" & varStaffName &
"' "
'Response.Write(SQLstr)
myConnection = New
SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("RCSConnectionString").ConnectionString)
myConnection.Open()
myCommand = New SqlCommand(SQLstr, myConnection)
dr = myCommand.ExecuteReader()
txtStaffID.Text = ""
lblRegNumber.Text = ""
lblVCNumber.Text = ""
lblPosition.Text = ""
lblFullName.Text = ""
txtTier.Text = ""
txtWorkPhone.Text = ""
txtHomePhone.Text = ""
txtMobilePhone.Text = ""
While dr.Read()
txtStaffID.Text = dr.GetString(0)
lblRegNumber.Text = dr.GetString(1)
lblVCNumber.Text = dr.GetString(2)
lblPosition.Text = dr.GetString(3)
lblFullName.Text = dr.GetString(4)
txtTier.Text = dr.GetValue(5)
txtWorkPhone.Text = dr.GetString(6)
txtHomePhone.Text = dr.GetString(7)
txtMobilePhone.Text = dr.GetString(8)
End While
dr.Close()
dr.Dispose()
myConnection.Close()
myConnection.Dispose()
End If
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Dim connectionString As String =
System.Configuration.ConfigurationManager.ConnectionStrings("RCSConnectionString").ConnectionString
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim SQLstr As String
Dim icount As Integer
Dim varTier As Integer
Dim varWorkPhone2 As String
Dim varHomePhone2 As String
Dim varMobilePhone2 As String
Dim varStaffID As String
Dim varCallingStaffID As String
'txtTier = form1.FindControl("txtTier")
'txtWorkPhone = form1.FindControl("txtWorkPhone")
'txtHomePhone = form1.FindControl("txtHomePhone")
'txtMobilePhone = form1.FindControl("txtMobilePhone")
'Dim varTier = form1.FindControl("txtTier")
'Dim varWorkPhone2 =
form1.FindControl("txtWorkPhone").ToString
'Dim varHomePhone2 =
form1.FindControl("txtHomePhone").ToString
'Dim varMobilePhone2 =
form1.FindControl("txtMobilePhone") .ToString
varTier = txtTier.Text
varWorkPhone2 = txtWorkPhone.Text
varHomePhone2 = txtHomePhone.Text
varMobilePhone2 = txtMobilePhone.Text
varStaffID = txtStaffID.Text
varCallingStaffID = "0999820227"
SQLstr = " UPDATE tblCallTree "
SQLstr = SQLstr & " SET Tier = '" & varTier & "', WorkPhone
= '" & varWorkPhone2 & "', "
SQLstr = SQLstr & " HomePhone = '" & varHomePhone2 & "',
MobilePhone = '" & varMobilePhone2 & "', "
SQLstr = SQLstr & " DataEntryDate = GetDate(), Completed =
1, CallingStaffID = '" & varCallingStaffID & "' "
SQLstr = SQLstr & " WHERE StaffID = '" & varStaffID & "' "
'Update will set Completed = True
myConnection = New
SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("RCSConnectionString").ConnectionString)
Response.Write(SQLstr)
myConnection.Open()
'Get Identity
myCommand = New SqlCommand(SQLstr, myConnection)
icount = myCommand.ExecuteNonQuery
myConnection.Close()
myConnection.Dispose()
End Sub
End Class