变量i页面加载创造了单页(背后的.vb代码)和创建公共intFileID作为整数如何坚持回发
我检查查询字符串,如果可用或设置intFileID = 0它分配
Public intFileID As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Not Request.QueryString("fileid") Is Nothing Then
intFileID = CInt(Request.QueryString("fileid"))
End If
If intFileID > 0 Then
GetFile(intFileID)
End If
End If
End Sub
Private Sub GetFile()
'uses intFileID to retrieve the specific record from database and set's the various textbox.text
End Sub
提交按钮的单击事件可以根据intFileID变量的值插入或更新记录。我需要能够在回发中坚持这一价值,才能发挥作用。
该页面只是插入或更新SQL数据库中的记录。我没有使用gridview,formview,detailsview,或任何其他rad类型的对象,它自己坚持键值,我不想使用它们中的任何一个。
如何在intFileID中持续设置值而不在HTML中创建可能会更改的内容。
[编辑]更改Page_Load中使用的ViewState来持久intFileID值
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Not Request.QueryString("fileid") Is Nothing Then
intFileID = CInt(Request.QueryString("fileid"))
End If
If intFileID > 0 Then
GetFile(intFileID)
End If
ViewState("intFileID") = intFileID
Else
intFileID = ViewState("intFileID")
End If
End Sub
哇。不要点击链接。垃圾邮件城市。 – 2015-11-30 15:52:53
哎呀。自2008年以来必须改变。删除它。 – jerhinesmith 2015-11-30 23:06:39