Tom Chesley
Member
- Joined
- Jun 18, 2006
- Messages
- 12
- Programming Experience
- 1-3
I have a web form that retrieves information from a database depeinding on the item selected in a listbox and placing the information in some textboxes that I then wish to be able to edit and put back the edited information in the database
When I edit the textbox, the textbox.text value didnt change.
Included is some of the code I'm using
Another weird thing is when I click the save button, nothing happens until I click it the second time.
When I edit the textbox, the textbox.text value didnt change.
Included is some of the code I'm using
Another weird thing is when I click the save button, nothing happens until I click it the second time.
VB.NET:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim tagID As String = Request.QueryString("tagID")
lblUser.Text = "Welcome " + tagID
If lblUser.Text = "" Then
' Response.Redirect("[URL]http://tonkas.no-ip.org/Jedi/JediMembers.aspx[/URL]")
End If
daMembers.Fill(dsMembers)
lbName.DataBind()
tbName.DataBind()
If Not Page.IsPostBack Then
ListLoad()
lbName.SelectedIndex = 0
End If
Dim oCmd As SqlClient.SqlCommand
Dim oReader As SqlClient.SqlDataReader
Dim selJedi As String = "SELECT JediName, JediLevel, Status, Updated, Updater, Email, Jnum FROM Jedi"
selJedi &= " WHERE JediName = "
selJedi &= "'" + lbName.SelectedItem.Value + "'"
oCmd = New SqlClient.SqlCommand(selJedi, con)
Try
If con.State = ConnectionState.Closed Then
con.Open()
End If
oReader = oCmd.ExecuteReader(CommandBehavior.CloseConnection)
'loop reader to retreive data
'set textbox to appropiate data
While oReader.Read
With oReader
tbNum.Text = .Item("Jnum")
tbName.Text = .Item("JediName")
tbLevel.Text = .Item("JediLevel")
tbStatus.Text = .Item("Status")
tbUpdated.Text = .Item("Updated")
tbUpdater.Text = .Item("Updater")
tbEmail.Text = .Item("Email")
End With
End While
Catch ex As Exception
lblMsg.Text = ex.Message
Finally
con.Close()
End Try
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'tbLevel.Dispose()
'none of the textboxs are changed?
Dim UpdateCMD As SqlClient.SqlCommand
Dim UpdateJedi As String = "UPDATE Jedi SET "
UpdateJedi &= "JediName = '" + tbName.Text + "', "
UpdateJedi &= "JediLevel = '" + tbLevel.Text + "', "
UpdateJedi &= "Status = '" + tbStatus.Text + "', "
UpdateJedi &= "Updated = '" + tbUpdated.Text + "', "
UpdateJedi &= "Updater = '" + tbUpdater.Text + "', "
UpdateJedi &= "Email = '" + tbEmail.Text + "' "
UpdateJedi &= "WHERE Jnum = '" + tbNum.Text + "'"
UpdateCMD = New SqlClient.SqlCommand(UpdateJedi, con)
Try
con.Open()
UpdateCMD.ExecuteNonQuery()
Catch ex As Exception
lblMsg.Text = ex.Message
Finally
con.Close()
End Try
End Sub
Last edited: