如何更改文本框?

时间:2015-06-03 02:15:09

标签: vb.net

我正在进行更新,所以我所做的就是使用select语句从数据库中获取。然后将其显示在透视文本框中。但它没有更新到新提供的日期,而是使用原始日期。有人可以帮忙吗?我需要使用textChanged还是有其他方法?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load   

    Dim sqlstr As String = "SELECT * FROM Card WHERE CardID='" & Request.QueryString("id") & "'"
    Dim CardDt As DataTable = DBadapter.GetDataTable(sqlstr)

    Dim count = 0

    TextBox1.Text = CardDt.Rows.Item(count).Item("Date")

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

    Dim sqlstr2 As String = "Update Card Set Date='" & TextBox1.Text & "' WHERE Card_Code=" & MM_recordId

    Dim UpdateDt As DataTable = DBadapter.GetDataTable(sqlstr2)

End Sub

1 个答案:

答案 0 :(得分:0)

我在页面加载时使用IsPostBack。

If Not IsPostBack Then

   Code to read data from database

End If