我是使用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