View Single Post
  #4 (permalink)  
Old February 28th, 2006, 01:19 PM
wirerider wirerider is offline
Authorized User
Points: 514, Level: 8
Points: 514, Level: 8 Points: 514, Level: 8 Points: 514, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply.

Here are the key code elements:

=================the key page elements (other than the gridview, which is generated entirely from the designer)

       <asp:HiddenField ID="Hidden1" runat="server" value = ""/>
        <input id="Button1" type="button" style="z-index:103; left: 180px; position: absolute; top: 8px;" onClick="javascript:Button1Click()" value="button" />
        <input id="Text1" style="z-index: 104; left: 16px; position: absolute; top: 8px"
        type="text" />
============client code

<script language=javascript>
//-------------------------
function GetElem(varString){return document.getElementById(varString) }
//-------------------------
function Button1Click() {
    //alert(GetElem("Hidden1").value)
    alert("text1 = " + GetElem("Text1").value);
    GetElem("Hidden1").value = GetElem("Text1").value
    alert("Hidden1 = " + GetElem("Hidden1").value);
    document.forms[0].submit();
    }
 alert ("set hidden1 to blank")
 GetElem("Hidden1").value = ""
 </script>


===============code behind

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            If Me.Hidden1.Value.Trim <> "" Then
                MsgBox("updating at server " & Me.Hidden1.Value)
                Dim DB As New DB 'the database maintenance class
                Call DB.AddRecord(Me.Hidden1.Value)
                Me.Hidden1.Value = ""
            End If
        End If
    End Sub

=================================

The DB gets updated...I can see the new record in the table, and the gridview will show it if I recompile.

However,the gridview doesn't refresh, even on a page refresh.

Also, for some reason the value of "Hidden1" doesn't get reset to blanks, so on each page load, it sees a non-blank value in Hidden1, and updates the database again.

Any insight on these points would be appreciated.

Thanks!
Reply With Quote