我是使用asp.net的新手,我在更新數據後如何刷新GridView
出現問題,但看起來它不適用於其他頁面。當我更新供應商信息時,我有相同的代碼,然後GridView1.Databind()
正在工作,但是當我嘗試在我的其他頁面上再次使用它時,它不起作用。你能否說出爲什麼會發生這種情況?如何刷新gridview?
這裏是我的代碼:
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim cmd As New SqlCommand
cmd.Connection = cn
cmd.CommandText = "UPDATE ProductTable SET ProductCode = ('" & lbl_productcode.Text & "'), ProductName = ('" & txt_prodname.Text & "'),ProductCategory =('" & lbl_category.Text & "'),Price =('" & txt_price.Text & "'), Quantity=('" & txt_qty.Text & "'), CategoryID=('" & lbl_catid.Text & "') WHERE ProductCategory = '" & TextBox1.Text & "'"
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
MsgBox("RECORD UPDATED", MsgBoxStyle.Information)
GridView1.DataBind()
Call clear()
End Sub
由於我主要使用*企業Java *和*移動應用程序*,我不是很熟悉asp.net,雖然只是說,因爲asp.net支持服務器控件,不應該有需要像你說的那樣刷新'GridView',你是什麼意思*「在我的其他頁面上它不起作用」**?我真的不明白你想說什麼,以及你的查詢是什麼。 – Lion 2011-12-26 15:44:06
Arrgh! [Little Bobby Tables](http://imgs.xkcd.com/comics/exploits_of_a_mom.png)檢測到! – 2011-12-26 15:51:47