Labels Not Updating After GridView has changed

I have a web page that has a gridview on it.  The gridview allows for editing, updating and deleting records.  I have two labels that appear outside the gridview that inform the user as to whether the gridview is or isn't in balance over has to many lines.  Currently, I have the code attached to a submit button which fires correctly, but only when you hit the submit button which is only used to call the transaction.  Also if I use GridView1.Databind() on the page load it causes my footer in the GridView to double the dollar that the transaction is off.  The transaction is to net to zero.

So the 500 Point question is how do I fire those labels without using the submit button each time after a row has been updated.

Just so you know I am using a standard VS 2005, canned GridView with the ShowEdit and ShowDelete buttons, so nothing fancy.
ASPX Page:
<br />
<div style="text-align:center"><asp:Label Text="1st WARNING" ForeColor="red" Font-Bold="true" Visible="false" ID="Warning" runat="server" /></div>
<div style="text-align:center"><asp:Label Text="2nd WARNING" ForeColor="red" Font-Bold="true" Visible="false" ID="Warning2" runat="server" /></div>
 
ASPX.VB Code - Submit Button
 
    Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitBtn.Click
 
        GridView1.DataBind()
 
        RowCount.Text = GridView1.Rows.Count
 
        If CType(RowCount.Text, Integer) > 50 Or GetTotal() <> "0.00" Then
            IndexBtn.Visible = False
            Warning.Visible = True
            Warning.Text = ("THE TRANSACTION IS EITHER OUT OF BALANCE OR EXCEEDS 50 LINES," _
            & " CHECK THE TOTAL AND NUMBER OF RECORDS IN THE GRID!!!")
        Else
            IndexBtn.Visible = True
            Warning.Visible = False
        End If
 
    End Sub

Open in new window

gagnonmvAsked:
Who is Participating?
 
Christian de BellefeuilleProgrammerCommented:

    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        RowCount.Text = GridView1.Rows.Count
 
        If CType(RowCount.Text, Integer) > 50 Or GetTotal() <> "0.00" Then
            IndexBtn.Visible = False
            Warning.Visible = True
            Warning.Text = ("THE TRANSACTION IS EITHER OUT OF BALANCE OR EXCEEDS 50 LINES," _
            & " CHECK THE TOTAL AND NUMBER OF RECORDS IN THE GRID!!!")
        Else
            IndexBtn.Visible = True
            Warning.Visible = False
        End If
    End Sub

Open in new window

0
 
Christian de BellefeuilleProgrammerCommented:
Why don't you try to use the RowDataBound or DataBound events of your gridview to update theses labels?
0
 
gagnonmvAuthor Commented:
Awesome, It worked, Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.