Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在页面加载上调用函数LordRecord()不会在单击ASP.NET按钮时更新数据_Asp.net - Fatal编程技术网

在页面加载上调用函数LordRecord()不会在单击ASP.NET按钮时更新数据

在页面加载上调用函数LordRecord()不会在单击ASP.NET按钮时更新数据,asp.net,Asp.net,实际上没有错误,只是在单击按钮后我似乎无法更新,因为在页面加载上调用LoadRecords(),我尝试删除Call LoadRecords(),是的,我能够更新。有人知道怎么解决这个问题吗?我将非常感激,谢谢 请不要理会我的评论。您应该使用If Not Page.IsPostBack 在页面加载时尝试以下操作: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.L

实际上没有错误,只是在单击按钮后我似乎无法更新,因为在页面加载上调用
LoadRecords()
,我尝试删除
Call LoadRecords()
,是的,我能够更新。有人知道怎么解决这个问题吗?我将非常感激,谢谢

请不要理会我的评论。您应该使用If Not Page.IsPostBack

在页面加载时尝试以下操作:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ToString())
    If Not Request.Cookies("UsernameCookie") Is Nothing Then
        Dim cookie As String = Server.HtmlEncode(Request.Cookies("UsernameCookie").Value)
        Dim acc() As String
        acc = Split(cookie, "=")
        username = acc(1)
        Call LoadRecords()
    Else
        Response.Redirect("Login.aspx")
    End If
End Sub

    Protected Sub btnSavePD_Click(ByVal sender As Object, ByVal e As EventArgs)

    cmd3 = New SqlCommand
    cmd3.CommandText = "Update_Details"
    cmd3.CommandType = CommandType.StoredProcedure
    cmd3.Parameters.AddWithValue("@username", username.Trim())
    cmd3.Parameters.AddWithValue("@fname", txtFirstname.Text)
    cmd3.Parameters.AddWithValue("@lname", txtLastname.Text)
    cmd3.Parameters.AddWithValue("@address", txtAddress.Text)

    cmd3.Connection = con
    con.Open()
    cmd3.ExecuteNonQuery()
    con.Close()
    Page.ClientScript.RegisterStartupScript([GetType](), "CallMyFunction", "Success();", True)
End Sub

我应该从页面加载中删除LoadRecords()吗?我想在页面加载时显示数据。
If Not Page.IsPostBack Then
   LoadRecords() 
End If