View Single Post
  #6 (permalink)  
Old February 28th, 2006, 04:33 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 the input.

I got it to work, except for the fact that it doesn't seem to clear out the hidden1 value, so keeps re-adding to the db with each page refresh. But I don't think that's a gridview refresh issue, so I'm going to try to isolate it and figure it out separately.

Here's the solution I arrived at (with thanks to several parties in different forums for promptings that eventually got me to this.)

=====key page elements (except completely vanilla gridview, created in designer, and form1 method = "post")

<input type=hidden 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" />

===========javascript
<script>
function Button1Click() {
    document.form1.Hidden1.value = document.form1.Text.value
    document.forms[0].submit(); // not very complicated here...a nice surprise
    }
</script>

===========codebehind

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If IsPostBack Then
            If Trim(Me.Hidden1.Value) <> "" Then ' the re-add hidden1 gets past this :-/
                Dim DB As New DB
                Call DB.AddRecord(Me.Hidden1.Value) ' the db update method
                Me.Hidden1.Value = "" ' the re-add gets past this, too :-/
                Me.GridView1.DataBind() ' this was the missing piece for a while
            End If
        End If

    End Sub
Reply With Quote